tags:

views:

137

answers:

1

I want to draw 15 images in drawRect: but the biggest I could find was NSDrawNinePartImage() I want 4 corners, top/bottom fill, and 3 rows between them (two side fills and a center fill)

What is recommended here? NinePart + 2 * ThreePart? Or something else?

A: 

NSDrawNinePartImage is for drawing a single thing that's divided into nine aligned sections like a tic-tac-toe/noughts-and-crosses board.

The primary use case for that is a rounded-rectangle UI element, such as a button. You'd have four fixed-size corners, four uniaxially-stretchable sides, and one biaxially-stretchable center.

That doesn't fit with what you're describing. Three center columns?

If the two extra columns should be fixed in horizontal size, then put each end's images together into a single image per corner and per side. Then use NSDrawNinePartImage as normal.

If the two extra columns are part of the center column and so should be horizontally stretchable, then I suggest that you use NSDrawThreePartImage from inside an NSCustomImageRep subclass and use an instance of that subclass for each of three center-column part images. Then use NSDrawNinePartImage as normal.

(Substitute “rows” for “columns” and “vertically” for “horizontally” in the previous three paragraphs if you want.)

Peter Hosey
Thank you. I'll take a look at what NSCustomImageRep gives me.
David Bleu
It doesn't give you anything. It's exactly what it says: A *custom* image rep. You subclass it and then you implement it.
Peter Hosey