UISegmentControl
2018-12-06 本文已影响0人
Shorebloom_59f6
常用方法
- 新增一个文字segment
- (void)insertSegmentWithTitle:(nullable NSString *)title atIndex:(NSUInteger)segment animated:(BOOL)animated;
- 新增一个图片segment
- (void)insertSegmentWithImage:(nullable UIImage *)image atIndex:(NSUInteger)segment animated:(BOOL)animated;
- 删除某个segment
- (void)removeSegmentAtIndex:(NSUInteger)segment animated:(BOOL)animated;
- 删除所有segment
- (void)removeAllSegments;
- 设置某个segment标题
- (void)setTitle:(nullable NSString *)title forSegmentAtIndex:(NSUInteger)segment;
- 获取某个segment标题
- (nullable NSString *)titleForSegmentAtIndex:(NSUInteger)segment;
- 设置某个segment图片
- (void)setImage:(nullable UIImage *)image forSegmentAtIndex:(NSUInteger)segment;
- 获取某个segment图片
- (nullable UIImage *)imageForSegmentAtIndex:(NSUInteger)segment;
- 设置某个segment宽度
- (void)setWidth:(CGFloat)width forSegmentAtIndex:(NSUInteger)segment;
- 获取某个segment宽度
- (CGFloat)widthForSegmentAtIndex:(NSUInteger)segment;
- 设置segment内容偏移量
- (void)setContentOffset:(CGSize)offset forSegmentAtIndex:(NSUInteger)segment;
- 获取某个segment内容偏移量
- (CGSize)contentOffsetForSegmentAtIndex:(NSUInteger)segment;
- 设置某个segment是否可用,默认为
YES
- (void)setEnabled:(BOOL)enabled forSegmentAtIndex:(NSUInteger)segment;
- 获取某个segment是否可用
- (BOOL)isEnabledForSegmentAtIndex:(NSUInteger)segment;
- 设置背景图
- (void)setBackgroundImage:(nullable UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics
- 设置分隔线图片
- (void)setDividerImage:(nullable UIImage *)dividerImage forLeftSegmentState:(UIControlState)leftState rightSegmentState:(UIControlState)rightState barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0)
- 获取分隔线图片
- (nullable UIImage *)dividerImageForLeftSegmentState:(UIControlState)leftState rightSegmentState:(UIControlState)rightState barMetrics:(UIBarMetrics)barMetrics
- 设置标题富文本属性
- (void)setTitleTextAttributes:(nullable NSDictionary *)attributes forState:(UIControlState)state NS_AVAILABLE_IOS(5_0)
- 获取富文本属性
- (void)setTitleTextAttributes:(nullable NSDictionary *)attributes forState:(UIControlState)state NS_AVAILABLE_IOS(5_0)