UISegmentControl

常用方法

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

你可能感兴趣的:(UISegmentControl)