Created
August 1, 2012 20:33
-
-
Save C4Examples/3230481 to your computer and use it in GitHub Desktop.
UIColor System Colors
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.h | |
| // Examples | |
| // | |
| // Created by Travis Kirton | |
| // | |
| #import "C4Workspace.h" | |
| @interface C4WorkSpace () | |
| -(void)setupShapes; | |
| -(void)setupLabels; | |
| @end | |
| @implementation C4WorkSpace { | |
| //we use an array of shapes and for() loops to set styles | |
| NSArray *shapes; | |
| } | |
| -(void)setup { | |
| [self setupShapes]; | |
| [self setupLabels]; | |
| //We cast each object in the array to a C4Shape object, and then set its color | |
| ((C4Shape *)[shapes objectAtIndex:0]).fillColor = [UIColor underPageBackgroundColor]; | |
| ((C4Shape *)[shapes objectAtIndex:1]).fillColor = [UIColor scrollViewTexturedBackgroundColor]; | |
| ((C4Shape *)[shapes objectAtIndex:2]).fillColor = [UIColor viewFlipsideBackgroundColor]; | |
| ((C4Shape *)[shapes objectAtIndex:3]).fillColor = [UIColor darkTextColor]; | |
| //lightTextColor is actually white with 60% opacity | |
| ((C4Shape *)[shapes objectAtIndex:4]).fillColor = [UIColor lightTextColor]; | |
| //on iPad groupTableViewBackgroundColor is equivalent to [UIColor clearColor] | |
| ((C4Shape *)[shapes objectAtIndex:5]).fillColor = [UIColor groupTableViewBackgroundColor]; | |
| } | |
| -(void)setupShapes { | |
| //create a frame for building each shape | |
| CGRect frame = CGRectMake(0, 0, self.canvas.width*0.9f, self.canvas.height/9.0f); | |
| //create an array of 6 shapes | |
| shapes = [NSArray arrayWithObjects: | |
| [C4Shape rect:frame], | |
| [C4Shape rect:frame], | |
| [C4Shape rect:frame], | |
| [C4Shape rect:frame], | |
| [C4Shape rect:frame], | |
| [C4Shape rect:frame], | |
| nil]; | |
| //create a point that we can update to se the position of each object | |
| CGPoint center = self.canvas.center; | |
| CGFloat dy = self.canvas.height / 7.0f; | |
| center.y = dy; | |
| //for every shape, update its linewidth, position and add it to the canvas | |
| for(C4Shape *s in shapes) { | |
| s.lineWidth = 0.0f; | |
| s.center = center; | |
| center.y += dy; | |
| [self.canvas addShape:s]; | |
| } | |
| //[UIColor lightTextColor] is actually WHITE, with a 0.6 opacity | |
| //So, we set it to darkTextColor to see the difference between it and it's label | |
| ((C4Shape *)[shapes objectAtIndex:4]).backgroundColor = [UIColor darkTextColor]; | |
| ((C4Shape *)[shapes objectAtIndex:5]).shadowOffset = CGSizeMake(5,5); | |
| ((C4Shape *)[shapes objectAtIndex:5]).shadowOpacity = 0.8f; | |
| ((C4Shape *)[shapes objectAtIndex:5]).lineWidth = 1.0f; | |
| ((C4Shape *)[shapes objectAtIndex:5]).strokeColor = C4GREY; | |
| } | |
| -(void)setupLabels { | |
| //create a font for the labels | |
| C4Font *f = [C4Font fontWithName:@"ArialRoundedMTBold" size:20.0f]; | |
| C4Label *l; | |
| //create an array of texts for the labels | |
| NSArray *labelTexts = [NSArray arrayWithObjects:@"underPageBackgroundColor", | |
| @"scrollViewTexturedBackgroundColor", | |
| @"viewFlipsideBackgroundColor", | |
| @"darkTextColor", | |
| @"lightTextColor", | |
| @"groupTableViewBackgroundColor",nil]; | |
| //create a label for each shape and add it to the canvas | |
| for(int i = 0; i < [labelTexts count]; i ++) { | |
| l = [C4Label labelWithText:(NSString *)[labelTexts objectAtIndex:i] font:f]; | |
| //all labels will be white except the last two | |
| if(i < 4) l.textColor = [UIColor lightTextColor]; | |
| else l.textColor = [UIColor darkTextColor]; | |
| l.center = ((C4Shape *)[shapes objectAtIndex:i]).center; | |
| [self.canvas addLabel:l]; | |
| } | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment