Skip to content

Instantly share code, notes, and snippets.

@pita5
Created August 2, 2012 13:59
Show Gist options
  • Save pita5/3237297 to your computer and use it in GitHub Desktop.
Save pita5/3237297 to your computer and use it in GitHub Desktop.
@interface __PLGBorderTopButton : UIView
@property (nonatomic) PLGColor selectedColor;
@property (nonatomic) UIButton* button;
@end
@implementation __PLGBorderTopButton
- (id)forwardingTargetForSelector:(SEL)aSelector
{
return _button;
}
- (void)tapped
{
self.backgroundColor = [PLGTheme colorWithColor:_selectedColor];
}
- (void)layoutSubviews
{
CGRect f = self.frame;
CGFloat height = f.size.height-5;
CGFloat width = f.size.width;
_button.frame = CGRectMake(0, 5, width, height);
}
- (id)initWithColor:(PLGColor)color topColor:(PLGColor)topColor
{
self = [super initWithFrame:CGRectMake(0, 0, 100, 44.0f)];
if (self)
{
_button = [PLGTheme buttonWithColor:color];
[_button addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:NULL];
[self addSubview:_button];
_selectedColor = topColor;
self.backgroundColor = [PLGTheme colorWithColor:PLGWhite];
}
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment