// // CustomRadioGroup.h // JasonDevelop // // Created by Jason Lee on 3/10/14. // Copyright (c) jasondevelop. All rights reserved. // @import UIKit; @protocol CustomRadioGroupDelegate; @protocol CustomRadioReusableGroupDelegate; @protocol CustomRadioButtonDelegate @optional - (void)didCheckRadioButton:(id)sender; @end @interface CustomRadioButton : UIButton { @protected UIImage *_normalImage, *_highlightImage; UIImage *_bgNormalImage, *_bgHighlightImage; UIColor *_titleColorNormal, *_titleColorHighlight; UIEdgeInsets _insets; UIEdgeInsets _bgInsets; BOOL _checked; } @property (weak, nonatomic) id delegate; @property (strong, nonatomic) id value; @property (assign, nonatomic) BOOL checked; @property (assign, nonatomic) IBInspectable CGRect imageRect; //set with interfacebuilder @property (strong, nonatomic) UIImage *normalImage; @property (strong, nonatomic) UIImage *highlightImage; @property (strong, nonatomic) IBInspectable UIImage *bgImageNormal; @property (strong, nonatomic) IBInspectable UIImage *bgImageHighlight; @property (strong, nonatomic) IBInspectable UIColor *titleColorNormal; @property (strong, nonatomic) IBInspectable UIColor *titleColorHighlight; - (instancetype)initWithFrame:(CGRect)frame normalImage:(UIImage *)normalImage highlightImage:(UIImage *)highlightImage; - (BOOL)getRadioStatusFromValue; @end @interface CustomBgRadioButton : CustomRadioButton @property (assign, nonatomic) BOOL checked; @property (assign, nonatomic) IBInspectable CGRect rectForCapBg; //set with interfacebuilder - (instancetype)initWithFrame:(CGRect)frame bgNormalImage:(UIImage *)bgNormalImage bgHighlightImage:(UIImage *)bgHighlightImage rectForCapBg:(CGRect)rectForCapBg; @end //CAUTION: don't use in reusable tableview. @interface CustomRadioGroup : NSObject @property (weak, nonatomic) id delegate; @property (readonly, nonatomic) NSInteger count; @property (readonly, nonatomic) NSArray *rdoBtns; - (id)initWithRadioButtons:(id)buttons, ... NS_REQUIRES_NIL_TERMINATION; - (void)addRadioButton:(CustomRadioButton *)button; - (void)reset; - (id)valueForChecked; - (id)titleForChecked; - (void)someRadioButtonTouched:(id)sender; @end @protocol CustomRadioGroupDelegate @optional - (void)didSomeRadioButtonTouched:(id)sender; @end //use in resuable tableview @interface CustomRadioReusableGroup : NSObject @property (weak, nonatomic) id delegate; @property (weak, nonatomic) UITableView *tableView; @property (assign, nonatomic) NSInteger section; @property (readonly, nonatomic) id valueForChecked; @property (readonly, nonatomic) NSMutableArray *values; - (void)reset; - (void)addRadioButton:(CustomRadioButton *)rbtn; - (void)someRadioButtonTouched:(CustomRadioButton *)touchedRbtn; @end @protocol CustomRadioReusableGroupDelegate @optional - (void)didSomeReuableRadioButtonTouched:(id)sender; @end