Skip to content

Commit

Permalink
Changing initialisation to work with Coding as used by NIBs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattconnolly committed Oct 17, 2011
1 parent d3b53de commit a24cca2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions CoolButtons/CoolButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ @implementation CoolButton
@synthesize innerView=_innerView;
@synthesize highlightLayer=_highlightLayer;

- (void) awakeFromNib {
NSLog(@"Awake from nib called");
[self setButtonColor:[self backgroundColor]];
[self setBackgroundColor:[UIColor clearColor]];
[self buildView];
- (id)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (self) {
NSLog(@"initWithCoder");
[self setButtonColor:[self backgroundColor]];
[self setBackgroundColor:[UIColor clearColor]];
[self buildView];
}
return self;
}

- (id)initWithFrame:(CGRect)frame
Expand Down Expand Up @@ -78,9 +82,10 @@ - (void)setButtonColor:(UIColor *)value
-(void)drawRect:(CGRect)rect
{
NSLog(@"drawing the rect!");
for (int i = 0; i < [[[self.innerView layer] sublayers] count]; i++ ) {
while ([[[self.innerView layer] sublayers] count] > 0) {
[[[[self.innerView layer] sublayers] objectAtIndex:0] removeFromSuperlayer];
}

// create a view to store all the content
[self.innerView setBackgroundColor:[self buttonColor]];

Expand Down

0 comments on commit a24cca2

Please sign in to comment.