Skip to content

Instantly share code, notes, and snippets.

@Rich86man
Created May 2, 2013 04:22
Show Gist options
  • Save Rich86man/5500134 to your computer and use it in GitHub Desktop.
Save Rich86man/5500134 to your computer and use it in GitHub Desktop.
draw rect doesn't like bgColor
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
if (_currentGroup == nil) {
CGContextSetFillColorWithColor(context, kDefaultAccentColor.CGColor);
CGContextSetStrokeColorWithColor(context, kDefaultAccentColor.CGColor);
} else {
CGContextSetFillColorWithColor(context, [_appearanceContainer[_currentGroup] backgroundColor].CGColor);
CGContextFillRect(context, self.bounds);
CGContextSetFillColorWithColor(context, [_appearanceContainer[_currentGroup] accentColor].CGColor);
CGContextSetStrokeColorWithColor(context, [_appearanceContainer[_currentGroup] accentColor].CGColor);
// self.backgroundColor = [_appearanceContainer[_currentGroup] backgroundColor];
}
// Create the circles for "See more"
_rightCircle = CGRectMake((rect.size.width - 20), (kAppBarMinimalHeight/2 - kCircleSize/2), kCircleSize, kCircleSize);
_middleCircle = CGRectMake((_rightCircle.origin.x - 6), _rightCircle.origin.y, _rightCircle.size.width, _rightCircle.size.height);
_leftCircle = CGRectMake((_middleCircle.origin.x - 6), _middleCircle.origin.y, _middleCircle.size.width, _middleCircle.size.height);
CGContextFillEllipseInRect(context, _rightCircle);
CGContextFillEllipseInRect(context, _middleCircle);
CGContextFillEllipseInRect(context, _leftCircle);
[self.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[CommandButton class]]) {
[obj removeFromSuperview];
}
}];
for (CommandButton *button in [_buttonContainer objectForKey:_currentGroup]) {
if (button.containsMenuList) {
[button addTarget:self action:@selector(openMenuList:) forControlEvents:UIControlEventTouchUpInside];
} else {
[button addTarget:self action:@selector(buttonWasSelected:) forControlEvents:UIControlEventTouchUpInside];
}
[self addSubview:button];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment