您的位置:首页 > 产品设计 > UI/UE

iOS UISegmentedControl的基本使用方法

2016-10-23 00:00 381 查看
摘要: iOS UISegmentedControl

1.控件的初始化

UISegmentedControl*sc=[[UISegmentedControl alloc]initWithItems:@[@"1",@"2",@"3"]];
//initWithItems:(NSArray*)arr
sc.frame=CGRectMake(50,50, 100, 50);//设置位置




2.设置当前索引所在位置

sc.selectedSegmentIndex=1;




3.设置控件颜色

sc.tintColor=[UIColor blueColor];




4.修改指定位置的内容

[sc setTitle:@"100" forSegmentAtIndex:1];




6.设置点击后恢复原样

//默认为点击后保留点击效果,设置为yes后点击后恢复成原来的样子
sc.momentary=YES;


7.设置点击事件

[sc addTarget:self action:@selector(click:) forControlEvents:UIControlEventValueChanged];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: