Skip to content

dvkch/SYSegmentedControl

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

SYSegmentedControl

Custom component to recreate UISegmentedControl features on iOS and tvOS plus the following ones:

  • deselect all items
  • select multiple items
  • custom height
  • custom font
  • custom colors (on tvOS)

All may not be perfect, if you find a bug or need another feature feel free to send a pull request!

@protocol SYSegmentedControlDelegate <NSObject>

- (void)segmentedControl:(SYSegmentedControl *)segmentedControl
  changedSelectedIndexes:(NSIndexSet *)selectedIndexes;

@end

IB_DESIGNABLE
@interface SYSegmentedControl : UIView

@property (nonatomic, weak) IBOutlet id<SYSegmentedControlDelegate> delegate;
@property (nonatomic, strong)               NSArray <NSString *> *titles;
@property (nonatomic)                       NSArray <NSString *> *selectedTitles;
@property (nonatomic)         IBInspectable NSString        *titlesAsString;
@property (nonatomic)         IBInspectable NSString        *selectedTitlesAsString;
@property (nonatomic, strong) IBInspectable UIFont          *font;
@property (nonatomic, strong) IBInspectable NSIndexSet      *selectedIndexes;
@property (nonatomic, assign) IBInspectable CGFloat         height;
@property (nonatomic, assign) IBInspectable CGFloat         lineWidth;
@property (nonatomic, assign) IBInspectable CGFloat         marginBetweenItems;
@property (nonatomic, assign) IBInspectable UIEdgeInsets    itemsInsets;
@property (nonatomic, assign) IBInspectable BOOL            equalWidths;
@property (nonatomic, assign) IBInspectable BOOL            allowMultipleSelection;
@property (nonatomic, assign) IBInspectable BOOL            allowNoSelection;

#if TARGET_OS_TV
@property (nonatomic, strong) IBInspectable UIColor *textColor;
@property (nonatomic, strong) IBInspectable UIColor *focusedTextColor;
@property (nonatomic, strong) IBInspectable UIColor *focusedBackgroundColor;
@property (nonatomic, strong) IBInspectable UIColor *selectedTextColor;
@property (nonatomic, strong) IBInspectable UIColor *selectedBackgroundColor;
#endif

@end

License

Once again, do as you wish with this code, but if you like it drop me an email to say thanks ;)

About

Custom UISegmentedControl for iOS and tvOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published