码迷,mamicode.com
首页 > 其他好文 > 详细

UISegmentControl

时间:2016-01-02 20:15:52      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

创建UISegmentControl对象

UISegmentedControl *segmented = [[UISegmentedControl alloc] initWithItems:@[@"北京", @"上海", @"广州"]];

segmented.frame = CGRectMake(100, 100, 200, 40); 

segmented.selectedSegmentIndex = 2; //默认选中某个分段,按下标

segmented.tintColor = [UIColor greenColor]; //设置segmentControl的渲染颜色

[segmented setWidth:60 forSegmentAtIndex:1]; //单独设置某个分段的宽(此方法会在原有宽度的基础上压缩其它分段的宽度).

//设置分段控件上的字体的属性

NSDictionary *textDic = @{NSFontAttributeName:[UIFont SystemFontOfSize:16], NSForegroundColorAttributeName:[UIColor redColor] };

[segmented setTittleTextAttributes:textDic forState:UIControlStateNormal];

[segmented addTarget:self action:@selector(handleSegment:) forControlEvents:UIControlEventValueChanged]; //添加点击事件

UISegmentControl

标签:

原文地址:http://www.cnblogs.com/lion-witcher/p/5095031.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!