Created
July 26, 2012 15:44
-
-
Save C4Examples/3182808 to your computer and use it in GitHub Desktop.
Line Dash Pattern
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
| // | |
| // C4WorkSpace.m | |
| // Examples | |
| // | |
| // Created by Travis Kirton on 12-07-19. | |
| // | |
| #import "C4WorkSpace.h" | |
| @implementation C4WorkSpace { | |
| C4Shape *line1, *line2; | |
| } | |
| -(void)setup { | |
| //create end points for the first line | |
| CGPoint endPoints[2] = {CGPointMake(0, self.canvas.height/3),CGPointMake(self.canvas.width, self.canvas.height/3)}; | |
| //create the first line | |
| line1 = [C4Shape line:endPoints]; | |
| //shift the end points for the second line | |
| endPoints[0].y *= 2; | |
| endPoints[1].y *= 2; | |
| //create the second line | |
| line2 = [C4Shape line:endPoints]; | |
| //create a c-array dash pattern and set this for line1 | |
| CGFloat pattern[2] = {5,10}; | |
| [line1 setDashPattern:pattern pointCount:2]; | |
| //create an NSArray of numbers and set this as the dash pattern for line2 | |
| NSArray *patternArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:15],[NSNumber numberWithInt:30], nil]; | |
| line2.lineDashPattern = patternArray; | |
| //thicken the lines | |
| line1.lineWidth = 50.0f; | |
| line2.lineWidth = 50.0f; | |
| //add the lines to the canvas | |
| [self.canvas addShape:line1]; | |
| [self.canvas addShape:line2]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment