Tile more than 9 images with Cocoa
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 fil开发者_如何学JAVAl)
What is recommended here? NinePart + 2 * ThreePart? Or something else?
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.)
精彩评论