Created
March 21, 2011 13:13
-
-
Save eliaskg/879431 to your computer and use it in GitHub Desktop.
Button theming in Cappuccino
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
@implementation CPButton (MyCostumButton) | |
- (void)setCustomTheme | |
{ | |
var normalColorNormal = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:[ | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonNormalNormalLeft.png"] size:CGSizeMake(2, 24)], | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonNormalNormalMiddle.png"] size:CGSizeMake(1, 24)], | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonNormalNormalRight.png"] size:CGSizeMake(2, 24)] | |
] isVertical:NO]]; | |
var normalColorHighlighted = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:[ | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonNormalActiveLeft.png"] size:CGSizeMake(2, 24)], | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonNormalActiveMiddle.png"] size:CGSizeMake(1, 24)], | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonNormalActiveRight.png"] size:CGSizeMake(2, 24)] | |
] isVertical:NO]]; | |
[self setValue:normalColorNormal forThemeAttribute:"bezel-color" inState:CPThemeStateNormal]; | |
[self setValue:normalColorHighlighted forThemeAttribute:"bezel-color" inState:CPThemeStateHighlighted]; | |
var defaultColorNormal = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:[ | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonDefaultNormalLeft.png"] size:CGSizeMake(2, 24)], | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonDefaultNormalMiddle.png"] size:CGSizeMake(1, 24)], | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonDefaultNormalRight.png"] size:CGSizeMake(2, 24)] | |
] isVertical:NO]]; | |
var defaultColorHighlighted = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:[ | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonDefaultActiveLeft.png"] size:CGSizeMake(2, 24)], | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonDefaultActiveMiddle.png"] size:CGSizeMake(1, 24)], | |
[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:"controls/buttonDefaultActiveRight.png"] size:CGSizeMake(2, 24)] | |
] isVertical:NO]]; | |
[self setValue:defaultColorNormal forThemeAttribute:"bezel-color" inState:CPThemeStateDefault]; | |
[self setValue:defaultColorHighlighted forThemeAttribute:"bezel-color" inState:CPThemeStateDefault|CPThemeStateHighlighted]; | |
[self setValue:normalColorNormal forThemeAttribute:"bezel-color" inState:CPThemeStateDefault|CPThemeStateDisabled]; | |
//[self setValue:[CPColor whiteColor] forThemeAttribute:"text-color" inState:CPThemeStateDefault]; | |
// [self setValue:[CPColor colorWithHexString:@"161616"] forThemeAttribute:"text-shadow-color" inState:CPThemeStateDefault]; | |
// [self setValue:[CPColor colorWithHexString:@"999999"] forThemeAttribute:"text-color" inState:CPThemeStateDefault|CPThemeStateDisabled]; | |
// [self setValue:[CPColor colorWithHexString:@"eeeeee"] forThemeAttribute:"text-shadow-color" inState:CPThemeStateDefault|CPThemeStateDisabled]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment