Guest User

redSegmentedControl.h

a guest
Aug 17th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. #import <UIKit/UIKit.h>
  2.  
  3. typedef void (^IndexChangeBlock)(NSInteger index);
  4.  
  5. typedef enum {
  6. redSegmentedControlTypeText,
  7. redSegmentedControlTypeImages
  8. } redSegmentedControlType;
  9.  
  10. typedef enum {
  11. redSegmentedControlSelectionStyleTextWidthStrip, // Indicator width will only be as big as the text width
  12. redSegmentedControlSelectionStyleFullWidthStrip, // Indicator width will fill the whole segment
  13. redSegmentedControlSelectionStyleBox
  14. } redSegmentedControlSelectionStyle;
  15.  
  16. typedef enum {
  17. redSegmentedControlSelectionLocationUp,
  18. redSegmentedControlSelectionLocationDown
  19. } redSegmentedControlSelectionLocation;
  20.  
  21. enum {
  22. redSegmentedControlNoSegment = -1 // segment index for no selected segment
  23. };
  24.  
  25. @interface redSegmentedControl : UIControl
  26.  
  27. @property (nonatomic, strong) NSArray *sectionTitles;
  28. @property (nonatomic, strong) NSArray *sectionImages;
  29. @property (nonatomic, strong) NSArray *sectionSelectedImages;
  30.  
  31. @property (nonatomic, copy) IndexChangeBlock indexChangeBlock; // you can also use addTarget:action:forControlEvents:
  32.  
  33. @property (nonatomic, strong) UIFont *font; // default is [UIFont fontWithName:@"STHeitiSC-Light" size:18.0f]
  34. @property (nonatomic, strong) UIColor *textColor; // default is [UIColor blackColor]
  35. @property (nonatomic, strong) UIColor *selectedTextColor; // default is [UIColor blackColor]
  36. @property (nonatomic, strong) UIColor *backgroundColor; // default is [UIColor whiteColor]
  37. @property (nonatomic, strong) UIColor *selectionIndicatorColor; // default is R:52, G:181, B:229
  38. @property (nonatomic, assign) redSegmentedControlSelectionStyle selectionStyle; // Default is redSegmentedControlSelectionStyleTextWidthStrip
  39. @property (nonatomic, assign) redSegmentedControlSelectionLocation selectionLocation; // Default is redSegmentedControlSelectionLocationUp
  40. @property (nonatomic, assign) redSegmentedControlType type;
  41.  
  42. @property (nonatomic, assign) NSInteger selectedSegmentIndex;
  43. @property (nonatomic, readwrite) CGFloat height; // default is 32.0
  44. @property (nonatomic, readwrite) CGFloat selectionIndicatorHeight; // default is 5.0
  45. @property (nonatomic, readwrite) UIEdgeInsets segmentEdgeInset; // default is UIEdgeInsetsMake(0, 5, 0, 5)
  46.  
  47. - (id)initWithSectionTitles:(NSArray *)sectiontitles;
  48. - (id)initWithSectionImages:(NSArray *)sectionImages sectionSelectedImages:(NSArray *)sectionSelectedImages;
  49. - (void)setSelectedSegmentIndex:(NSUInteger)index animated:(BOOL)animated;
  50. - (void)setIndexChangeBlock:(IndexChangeBlock)indexChangeBlock;
  51.  
  52. @end
Advertisement
Add Comment
Please, Sign In to add comment