Created
April 4, 2013 15:03
-
-
Save demigod19892012/5311149 to your computer and use it in GitHub Desktop.
[IOS] Correct way to draw background using a pattern image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[NSGraphicsContext currentContext] saveGraphicsState]; | |
// Change the pattern phase. | |
[[NSGraphicsContext currentContext] setPatternPhase: | |
NSMakePoint(0,[self frame].size.height)]; | |
// Stick the image in a color and fill the view with that color. | |
NSImage *anImage = [NSImage imageNamed:@"bricks"]; | |
[[NSColor colorWithPatternImage:anImage] set]; | |
NSRectFill([self bounds]); | |
// Restore the original graphics state. | |
[[NSGraphicsContext currentContext] restoreGraphicsState]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment