YUSegment alternatives and similar libraries
Based on the "Switch" category.
Alternatively, view YUSegment alternatives based on common mentions on social networks and blogs.
-
HMSegmentedControl
A highly customizable drop-in replacement for UISegmentedControl. -
RAMPaperSwitch
:octocat: 🎚 RAMPaperSwitch is a Swift material design UI module which paints over the parent view when the switch is turned on. iOS library by @Ramotion -
BetterSegmentedControl
An easy to use, customizable replacement for UISegmentedControl & UISwitch. -
TwicketSegmentedControl
Custom UISegmentedControl replacement for iOS, written in Swift -
AIFlatSwitch
Nicely animated flat design switch alternative to UISwitch -
SJFluidSegmentedControl
A segmented control with custom appearance and interactive animations. Written in Swift 3.0. -
PinterestSegment
A Pinterest-like segment control with masking animation. -
AKASegmentedControl
🍫 Fully customizable Segmented Control for iOS -
LUNSegmentedControl
Customizable segmented control with interactive animation. -
MultiSelectSegmentedControl
UISegmentedControl remake that supports selecting multiple segments, vertical stacking, combining text and images. -
JTMaterialSwitch
A Customizable Switch UI for iOS, Inspired from Google's Material Design -
ViralSwitch
A UISwitch that infects its superview with its tint color. -
DynamicMaskSegmentSwitch
A segment switcher with dynamic text mask effect -
AnimatedSwitch
UISwitch which paints over the parent view with the color in Swift. -
Switcher
Swift - Custom UISwitcher with animation when change status -
Switch
💊 An iOS switch control implemented in Swift with full Interface Builder support
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of YUSegment or a related project?
README
YUSegment
A customizable segmented control for iOS.
Features
- Supports both (Attributed)text and image
- Supports show separator
- Supports hide indicator
- Indicator could be located at the top and bottom
- YUSegment works on iOS 8.0+ and is compatible with ARC projects
Installation
Cocoapods
- Add a pod entry to your Podfile
pod 'YUSegment'
- Running
pod install
#import <YUSegment/YUSegment.h>
where you need
Carthage
github "afishhhhh/YUSegment"
Usage
YUSegmentedControl
inherits from UIControl
, supports Target-Action
.
YUSegmentedControl *segmentedControl = [[YUSegmentedControl alloc] initWithTitles:@[@"健身", @"摄影", @"科技", @"美食", @"旅行"]];
[self.view addSubview:segmentedControl];
[segmentedControl addTarget:self action:@selector(segmentedControlTapped:) forControlEvents:UIControlEventValueChanged];
By default, the background color of segmented control is whiteColor
, the color of indicator is darkGrayColor
, the height of indicator is 3.0, the color of separator is #e7e7e7
.
APIs
Methods
- (instancetype)initWithTitles:(NSArray <NSString *> *)titles;
- (instancetype)initWithImages:(NSArray <UIImage *> *)images;
- (instancetype)initWithImages:(NSArray <UIImage *> *)images
selectedImages:(nullable NSArray <UIImage *> *)selectedImages;
You can use selectedImages
if you want to show different images when a specific segment selected.
- (nullable NSString *)titleAtIndex:(NSUInteger)index;
- (nullable UIImage *)imageAtIndex:(NSUInteger)index;
You can get the corresponding text or image based on a specific index.
- (void)showBadgeAtIndexes:(NSArray <NSNumber *> *)indexes;
- (void)hideBadgeAtIndex:(NSUInteger)index;
example:
[segmentedControl show BadgeAtIndexes:@[@1, @2]];
- (void)setTextAttributes:(nullable NSDictionary *)attributes
forState:(YUSegmentedControlState)state;
The attributes for text. For a list of attributes that you can include in this dictionary, see Character Attributes.
The value of state
could be YUSegmentedControlNormal
and YUSegmentedControlSelected
.
example:
[segmentedControl setTextAttributes:@{
NSFontAttributeName: [UIFont systemFontOfSize:20.0 weight:UIFontWeightLight],
NSForegroundColorAttributeName: [UIColor blackColor]
} forState:YUSegmentedControlNormal];
Properties
- numberOfSegments(NSUInteger, readonly)
return the number of segments in a segmented control.
- selectedSegmentIndex(NSUInteger, readonly)
The index number identifying the selected segment. Default is 0.
- horizontalPadding
Default is 0.
If assign it to 32.0.
- showsTopSeparator
A Boolean value that controls whether the top separator is visible. Default is YES
.
- showsBottomSeparator
A Boolean value that controls whether the bottom separator is visible. Default is YES
.
- showsVerticalDivider
A Boolean value that controls whether the vertical divider is visible. Default is NO
.
- showsIndicator
A Boolean value that controls whether the indicator is visible. Default is YES
.
- backgroundColor(YUSegmentedControl)
The background color of segmented control. Default is white.
- height(YUSegmentedControlIndicator)
The height of indicator. Default is 3.0. You should use this property like this:
segment.indicator.height = 3.0;
- locate(YUSegmentedControlIndicator)
The vertical alignment of indicator. Default is YUSegmentedControlIndicatorLocateBottom
. Also could be YUSegmentedControlIndicatorLocateTop
You should use this property like this:
segment.indicator.locate = YUSegmentedControlIndicatorLocateTop;
- backgroundColor(YUSegmentedControlIndicator)
The background color of indicator. Default is dark gray. You should use this property like this:
segment.indicator.backgroundColor = [UIColor whiteColor];
License
This code is distributed under the terms and conditions of the [MIT license](LICENSE).
*Note that all licence references and agreements mentioned in the YUSegment README section above
are relevant to that project's source code only.