Created
November 4, 2013 17:36
-
-
Save C4Code/7306283 to your computer and use it in GitHub Desktop.
Defining Colors. This example shows how to define colors and use them in 2 different ways. First, it shows that you can use the newly defined variable in your app. Second, it shows how to set a the default style of an object (i.e. here it is a label) so that all other objects of the same time take the same default color when they are initialized.
This file contains 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 | |
// C4Code | |
// | |
// Created by Travis Kirton on 11/4/2013. | |
// | |
//Defines set in "stone" a value for a variable | |
//These are best to put in C4Defines.h, but here they suffice for this example | |
#define UA_NAV_BAR_COLOR [UIColor colorWithRed:0.96875 green:0.96875 blue:0.96875 alpha:1] | |
#define UA_NAV_CTRL_COLOR [UIColor colorWithRed:0 green:0 blue:0 alpha:0] | |
#define UA_BUTTON_COLOR [UIColor colorWithRed:0.8984275 green:0.8984275 blue:0.8984275 alpha:1] | |
#define UA_TYPE_COLOR [UIColor colorWithRed:0.19921875 green:0.19921875 blue:0.19921875 alpha:1] | |
#define UA_OVERLAY_COLOR [UIColor colorWithRed:0.19921875 green:0.19921875 blue:0.19921875 alpha:0.5] | |
#define UA_HIGHLIGHT_COLOR [UIColor colorWithRed:0.757 green:0.964 blue:0.617 alpha:0.5] | |
#define UA_DARKEN_COLOR [UIColor colorWithRed:0.19921875 green:0.19921875 blue:0.19921875 alpha:0.8] | |
#define UA_GREY_TYPE_COLOR [UIColor colorWithRed:0.3984375 green:0.3984375 blue:0.3984375 alpha:1.0] | |
@implementation C4WorkSpace | |
-(void)setup { | |
C4Shape *s = [C4Shape ellipse:CGRectMake(0, 0, 100, 100)]; | |
//now you don't need to pass the default colors between objects | |
s.fillColor = UA_BUTTON_COLOR; | |
s.strokeColor = UA_DARKEN_COLOR; | |
//you can set the default colors of various objects | |
//they will natively take this color when they are created | |
[C4Label defaultStyle].textColor = UA_GREY_TYPE_COLOR; | |
C4Label *l = [C4Label labelWithText:@"hello"]; | |
s.center = self.canvas.center; | |
l.center = self.canvas.center; | |
[self.canvas addObjects:@[s,l]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment