Created
January 18, 2012 22:01
-
-
Save MilkZoft/1636075 to your computer and use it in GitHub Desktop.
codejobs - Correct way to draw background using a pattern image - Objective-C
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
| // Save the current graphics state first so we can restore it. | |
| [[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