Latest 1.1.4
Homepage https://github.com/dvkch/SYSegmentedControl
License Custom, see Readme.md
Platforms ios 8.0, tvos 9.0, requires ARC
Dependencies SYKit
Authors

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 ;)

Latest podspec

{
    "name": "SYSegmentedControl",
    "version": "1.1.4",
    "license": "Custom, see Readme.md",
    "summary": "Custom UISegmentedControl",
    "homepage": "https://github.com/dvkch/SYSegmentedControl",
    "authors": {
        "Stan Chevallier": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dvkch/SYSegmentedControl.git",
        "tag": "1.1.4"
    },
    "source_files": "SYSegmentedControl/SYSegmentedControl.{h,m}",
    "requires_arc": true,
    "swift_version": "5.0",
    "xcconfig": {
        "CLANG_MODULES_AUTOLINK": "YES"
    },
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0"
    },
    "dependencies": {
        "SYKit": []
    }
}

Pin It on Pinterest

Share This