UISegment属性

1.segmentedControlStyle
设置segment的显示样式。
typedef NS_ENUM(NSInteger, UISegmentedControlStyle) {
UISegmentedControlStylePlain,     // large plain 系统默认平板样式
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;

UISegmentedControlStyleBordered,  // large bordered 黑边样式
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBordered;

UISegmentedControlStyleBar,       // small button/nav bar style. Tintable 条状样式
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;

UISegmentedControlStyleBezeled,   // DEPRECATED. Do not use this style. 这个类型不要使用,用了会报错喔。
};

2.tintColor 渐变颜色
Default tintColor is nil. Only used if style is UISegmentedControlStyleBar
默认空,只有使用UISegmentedControlStyleBar,才能设置渐变颜色。
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.tintColor = [UIColor redColor];

3.momentary 设置在点击后是否恢复原样
默认为NO
segmentedControl.momentary = No;

segmentedControl.momentary = YES;

4. numberOfSegments(只读)
获取总选项数segmentedControl.numberOfSegments

5. selectedSegmentIndex
用来设置选中项或者返回选中项。
segmentedControl.selectedSegmentIndex = 2;//设置默认选择项索引
segmentedControl.selectedSegmentIndex // 获取选中项
6.- (void)setTitle:(NSString *)title forSegmentAtIndex:(NSUInteger)segment;
[segmentedControl setTitle:@"two" forSegmentAtIndex:1];//设置指定索引的题目

7. - (void)setImage:(UIImage *)image forSegmentAtIndex:(NSUInteger)segment;       
[segmentedControl setImage:[UIImage imageNamed:@"lan.png"] forSegmentAtIndex:3];//设置指定索引的图片
8.-(void)insertSegmentWithTitle:(NSString*)title atIndex:(NSUInteger)segment animated:(BOOL)animated;
[segmentedControl insertSegmentWithTitle:@"add" atIndex:3 animated:NO];//在指定索引插入一个选项并设置题目

9.-(void)insertSegmentWithImage:(UIImage *)image  atIndex:(NSUInteger)segment animated:(BOOL)animated;
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"mei.png"] atIndex:2 animated:NO];//在指定索引插入一个选项并设置图片

10.- (void)removeSegmentAtIndex:(NSUInteger)segment animated:(BOOL)animated;
[segmentedControl removeSegmentAtIndex:0 animated:NO];//移除指定索引的选项

11. - (void)removeAllSegments;
    //移除所有选项
//[segmentedControl removeAllSegments];

12. - (void)setWidth:(CGFloat)width forSegmentAtIndex:(NSUInteger)segment;         // set to 0.0 width to autosize. default is 0.0
选项卡的宽度默认为0,此方法能够设置选项卡宽度。
[segmentedControl setWidth:70.0 forSegmentAtIndex:2];//设置指定索引选项的宽度

13. - (void)setContentOffset:(CGSize)offset forSegmentAtIndex:(NSUInteger)segment; // adjust offset of image or text inside the segment. default is (0,0)
[segmentedControl setContentOffset:CGSizeMake(10,0) forSegmentAtIndex:1];
设置选项卡内部文字或者图片与默认位置的偏移量,默认位置在选项卡的中心。

14. - (void)setEnabled:(BOOL)enabled forSegmentAtIndex:(NSUInteger)segment;

[segmentedControl setEnabled:NO forSegmentAtIndex:4];//设置指定索引选项不可选

15.增加事件响应机制
监听的是这个事件:UIControlEventValueChanged,值改变事件

[segmentedControl    addTarget:self    action:@selector(itemClick)    forControlEvents:UIControlEventValueChanged];

IOS开发UI基础UISegment属性的更多相关文章

  1. IOS开发UI基础文本属性Attributes

    文本属性Attributes 1.NSKernAttributeName: @10 调整字句 kerning 字句调整 2.NSFontAttributeName : [UIFont systemFo ...

  2. IOS开发UI基础UILabel属性

    UILabel属性 1.text:设置标签显示的文本. 2.attributedText:设置标签属性文本. Ios代码 NSString *text = @"first";  N ...

  3. IOS开发UI基础UIImageView属性属性

    UIImageView属性 1.Image 设置图片,默认显示 UIImageView *_imageView = [[UIImageView alloc]init]; _imageView.imag ...

  4. IOS开发UI基础UISlide属性

    UISlide属性 •    minimumValue  : 当值可以改变时,滑块可以滑动到最小位置的值,默认为0.0_slider.minimumValue = 10.0; •    maximum ...

  5. IOS开发UI基础UISwitch属性

    UISwitch属性1. onTintColor   处于on时switch 的颜色
    switchImage.onTintColor = [UIColor grayColor];2.tintC ...

  6. iOS开发UI基础—手写控件,frame,center和bounds属性

    iOS开发UI基础—手写控件,frame,center和bounds属性 一.手写控件 1.手写控件的步骤 (1)使用相应的控件类创建控件对象 (2)设置该控件的各种属性 (3)添加控件到视图中 (4 ...

  7. iOS开发UI篇—transframe属性(形变)

    iOS开发UI篇—transframe属性(形变) 1. transform属性 在OC中,通过transform属性可以修改对象的平移.缩放比例和旋转角度 常用的创建transform结构体方法分两 ...

  8. iOS开发UI篇—transframe属性(形变)

    iOS开发UI篇—transframe属性(形变) 1. transform属性 在OC中,通过transform属性可以修改对象的平移.缩放比例和旋转角度 常用的创建transform结构体方法分两 ...

  9. IOS开发UI基础--数据刷新

    IOS开发UI基础--数据刷新 cell的数据刷新包括下面几个方面 加入数据 删除数据 更改数据 全局刷新方法(最经常使用) [self.tableView reloadData]; // 屏幕上的全 ...

随机推荐

  1. Mybatis传多个参数(三种解决方案)

    第一种方案 DAO层的函数方法 Public User selectUser(String name,String area); 对应的Mapper.xml <select id="s ...

  2. Apex Design Patterns

    Apex allows you to build just about any custom solution on the Force.com platform. But what are the ...

  3. oratop 各个指标项说明

    Section 1- oratop and database/instance specifics spid       :oratop's server SPID connected to inst ...

  4. 将Sql Server迁移到Always on集群 - 账号的同步

    Always on环境的建立,网上资料很多,主要是windows集群的建立以及Sql Server Always on的建立,略 容易忽略的是Sql server账号同步问题(Always on能实现 ...

  5. java/.net-常用工具下载地址&常用学习网址&快捷键

    HTML5 HTML5:http://www.html5cn.org/ php常用网址 thinkphp框架:http://www.thinkphp.cn/ wampserver开发服务器:http: ...

  6. 3D立体显示大屏幕拼接视频墙系统解决方案【转】

    http://shop.souvr.com/thread-123416-1-1.html 随着3D立体视像.全息影像等技术不断取得突破性进展,国内外越来越多的公司投身3D显示领域,产品层出不穷.3D技 ...

  7. web项目中加入struts2、spring的支持,并整合两者

    Web项目中加入struts2 的支持 在lib下加入strut2的jar包 2. 在web.xml中添加配置 <filter> <filter-name>struts2< ...

  8. win10 Enable developer Mode

    经过漫长的安装过程 win10终于装上了vs2015 rc-   写个小程序试试 结果提示:   根据提示打开 设置--更新--for developer 据说应该有这么个界面:   但是这个界面根本 ...

  9. 为YAESU FT-817ND 增加频谱功能

    > ft817可谓是QRP神机啊,可能是一开始就接触SDR的缘故,没有频谱显示,总觉得很难受,好在经典的817从不缺乏魔改.终于找到一个解决方案: http://item.taobao.com/ ...

  10. 生成二维码 打上自定义logo

    private void RenderQrCode(string Code) { try { string level = "Q"; string url = ZConfig.Ge ...