|
@@ -9,6 +9,10 @@
|
|
|
|
|
|
@interface ProgramAddButton ()
|
|
|
|
|
|
+@property (weak, nonatomic) IBOutlet UIView *bgView;
|
|
|
+
|
|
|
+@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
|
|
|
+
|
|
|
@property (nonatomic, strong) UIColor *nomalBgColor;
|
|
|
|
|
|
@property (nonatomic, strong) UIColor *nomalTitleColor;
|
|
@@ -17,6 +21,10 @@
|
|
|
|
|
|
@property (nonatomic, strong) UIColor *selectedTitleColor;
|
|
|
|
|
|
+@property (nonatomic, assign) NSInteger buttonIndex;
|
|
|
+
|
|
|
+@property (nonatomic, copy) PraagamAddButtonCallback callback;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation ProgramAddButton
|
|
@@ -27,9 +35,41 @@
|
|
|
return view;
|
|
|
}
|
|
|
|
|
|
-- (void)configWithTitle:(NSString *)title nomalBgColor:(UIColor *)nomalBgColor nomalTitleColor:(UIColor *)nomalTitleColor selectedBgColor:(UIColor *)selectedBgColor selectedTitleColor:(UIColor *)selectedTitleColor {
|
|
|
+- (void)configWithTitle:(NSString *)title nomalBgColor:(UIColor *)nomalBgColor nomalTitleColor:(UIColor *)nomalTitleColor selectedBgColor:(UIColor *)selectedBgColor selectedTitleColor:(UIColor *)selectedTitleColor tag:(NSInteger)tagIndex {
|
|
|
+ self.titleLabel.text = title;
|
|
|
+ self.nomalBgColor = nomalBgColor;
|
|
|
+ self.nomalTitleColor = nomalTitleColor;
|
|
|
+ self.selectedBgColor = selectedBgColor;
|
|
|
+ self.selectedTitleColor = selectedTitleColor;
|
|
|
+ self.buttonIndex = tagIndex;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)buttonActionCallback:(PraagamAddButtonCallback)callback {
|
|
|
+ if (callback) {
|
|
|
+ self.callback = callback;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+- (IBAction)buttonAction:(id)sender {
|
|
|
+ if (self.callback) {
|
|
|
+ self.callback(self.buttonIndex);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+- (void)setIsChoose:(BOOL)isChoose {
|
|
|
+ _isChoose = isChoose;
|
|
|
+ if (isChoose) {
|
|
|
+ self.titleLabel.textColor = self.selectedTitleColor;
|
|
|
+ self.bgView.backgroundColor = self.selectedBgColor;
|
|
|
+ self.bgView.layer.borderColor = self.selectedTitleColor.CGColor;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.titleLabel.textColor = self.nomalTitleColor;
|
|
|
+ self.bgView.backgroundColor = self.nomalBgColor;
|
|
|
+ self.bgView.layer.borderColor = [UIColor clearColor].CGColor;
|
|
|
+ }
|
|
|
+}
|
|
|
/*
|
|
|
// Only override drawRect: if you perform custom drawing.
|
|
|
// An empty implementation adversely affects performance during animation.
|