代码:
//选择按钮
NSArray *buttonNames = [NSArray arrayWithObjects:@"今天", @"本周", @"本月", nil];
UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] initWithItems:buttonNames];
[segmentedControl setFrame:CGRectMake(60, 10, 200, 40)];
segmentedControl.selectedSegmentIndex=1;
//添加事件
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:segmentedControl];
[segmentedControl release];
//事件
-(void)segmentAction:(UISegmentedControl *)Seg{
NSInteger Index = Seg.selectedSegmentIndex;
NSLog(@"Seg.selectedSegmentIndex:%d",Index);
}
分享到:
相关推荐
iphone中的基础控件UISegmentedControl,适合初学者,主要学习UISegmentedControl的常用属性设置、点击事件、分段控制器,每一个按钮都有自己独立的功能,其数据源是一般是数组等
UISegmentedControl轻松使用
ios应用源码之自定义颜色的uisegmentedcontrol .
UISegmentedControl Demo代码,单选栏
用UISegmentedControl模拟TabbarController效果实现页面间的切换
自定义UISegmentedControl,源代码地址:https://github.com/STShenZhaoliang/STKitSwift
利用 UISegmentedControl 实现的滑块儿 Tab 效果.zip,iOS的自定义uisegmentedcontrol替换,用swift编写
UISegmentedControl分段控件代替了桌面OS上的单选按钮。不过它的选项个数非常有限,因为你的IOS设备屏幕有限。当我们需要使用选项非常少的单选按钮时它很合适。 一、创建 代码如下: UISegmentedControl* ...
IOS应用源码——自定义颜色的UISegmentedControl.zip
Android仿iOS7的UISegmentedControl 分段
IOS应用源码之自定义颜色的UISegmentedControl .rar
IOS应用源码之自定义颜色的UISegmentedControl.zip
一个视图中两个控制器来回的切换 UISegmentedControl UIwebView
采用Swift编写自定义UISegmentedControl实现的滑块Tab效果
前两年IOS应用源码-主要是用于毕业设计学习的。
UISegmentedControl使用ChildViewController切换UIViewcontroller
自定义UISegmentedControl空间
自定义颜色的UISegmentedControl.zipIOS应用例子源码下载自定义颜色的UISegmentedControl.zipIOS应用例子源码下载 1.适合学生学习研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考