UISegmentedControl详解:1-UISegmentedControl简介
在许多的应用程序中,开发者会加入一些主题选项以便对显示的信息做进一步分类。例如,App Store应用程序的排行榜导航栏上就显示着”付费”、”免费”、”畅销排行”选项,而这种展示方式就是通过UISegmentedControl来实现的。UISegmentedControl的使用方法类似于UIButton, 它不仅可以提供多个选择操作, 并且也可以响应交互事件。
UISegmentedControl常用属性和方法
在UISegmentedControl类中提供了用于初始化UISegmentedControl对象以及设置其外观的相关属性,下面的一些是在实际开发中比较常用的。
- 实例化方法。该方法中需要传递一个数组类型的items参数,在该参数中填写需要展示的标题(NSString类)或者图片(UIImage类)
- (instancetype)initWithItems:(nullable NSArray *)items;
- 当前选中的选项索引
@property(nonatomic) NSInteger selectedSegmentIndex;
- UISegmentedControl渲染的颜色
@property(null_resettable,nonatomic,strong) UIColor *tintColor;
- 设置指定索引的标题
- (void)setTitle:(nullable NSString *)title forSegmentAtIndex:(NSUInteger)segment;
- 设置指定索引的图片
- (void)setImage:(nullable UIImage *)image forSegmentAtIndex:(NSUInteger)segment;
- 设置指定索引选项的宽度
- (void)setWidth:(CGFloat)width forSegmentAtIndex:(NSUInteger)segment;
文章发布时间为: December 3rd , 2016 at 09:24 am
最后编辑时间为: September 15th , 2017 at 03:15 am
本文由 99ios 创作,转载请注明出处
最后编辑时间为: September 15th , 2017 at 03:15 am
本文由 99ios 创作,转载请注明出处