首页 > 其他 > 详细

UISegmentControl

时间:2016-01-02 20:14:08      阅读:232      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!