[self LimitedCountBtnInit];
[self LimitedTimeBtnInit];
- (void)LimitedCountBtnInit{
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGColorRef color = CGColorCreate(colorSpaceRef, (CGFloat[]){73/255,230/255,255/255,0.2});
self.LimitedCountBtn.layer.borderColor=color;
self.LimitedCountBtn.layer.borderWidth=1.0f;
self.LimitedCountBtn.layer.masksToBounds=YES;
[self.LimitedCountBtn addTarget:self action:@selector(LimitedCountBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.LimitedCountBtn addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:nil];
}
- (void)LimitedTimeBtnInit{
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGColorRef color = CGColorCreate(colorSpaceRef, (CGFloat[]){73/255,230/255,255/255,0.2});
self.LimitedTimeBtn.layer.borderColor=color;
self.LimitedTimeBtn.layer.borderWidth=1.0f;
self.LimitedTimeBtn.layer.masksToBounds=YES;
[self.LimitedTimeBtn addTarget:self action:@selector(LimitedTimeBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.LimitedTimeBtn addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:nil];
}
-(void)LimitedCountBtnClicked:(UIButton*)button{
[self.LimitedTimeBtn setSelected:NO];
[button setSelected:YES];
}
-(void)LimitedTimeBtnClicked:(UIButton*)button{
[self.LimitedCountBtn setSelected:NO];
[button setSelected:YES];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
UIButton *button = (UIButton *)object;
if ([keyPath isEqualToString:@"selected"]) {
if (button.selected) {
[button setBackgroundColor:[UIColor blueColor]];
return;
}
[button setBackgroundColor:[UIColor whiteColor]];
}
}