【UISegmentedControl】
来源:互联网 发布:ios软件免费下载 编辑:程序博客网 时间:2024/05/22 10:56
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window=[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]];
self.window.backgroundColor=[UIColorwhiteColor];
UIViewController *v=[[UIViewControlleralloc]init];
self.window.rootViewController=v;
[self.windowmakeKeyAndVisible];
//创建数组,内容是分段控件的各分区标题
NSArray *ns=[[NSArrayalloc]initWithObjects:@"enter",@"come",@"system",nil];
//创建分段控件
UISegmentedControl *segment=[[UISegmentedControlalloc]initWithItems:ns];
//设置控件大小
segment.frame=CGRectMake(30,40, 200, 50);
//初始选中第一位置的区
[segment setSelectedSegmentIndex:1];
//给控件设置目标事件
[segment addTarget:selfaction:@selector(visibel:)forControlEvents:UIControlEventValueChanged];
//创建标签及大小
label=[[UILabelalloc]initWithFrame:CGRectMake(250,40, 70, 50)];
label.backgroundColor=[UIColorgreenColor];
[self.windowaddSubview:segment];
[self.windowaddSubview:label];
//UIViewController *v=[[UIViewController alloc]init];
return YES;
}
-(void)visibel:(UISegmentedControl *)sender
{
//测试控件各分区的索引位置
NSLog(@"%d",(int)[senderselectedSegmentIndex]);
//让标签显示的文本等于当前选中的控件分区标题
label.text=[sendertitleForSegmentAtIndex:[sender selectedSegmentIndex]];
//文本方向置中
label.textAlignment=NSTextAlignmentCenter;
}
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- UISegmentedControl
- 【UISegmentedControl】
- cuda
- BAPC2014 C&&HUNNU11583:Citadel Construction(几何)
- 采用servlet请求读流展示页面图片
- JNI 错误:Fatal signal 11 (SIGSEGV) at 0x00000008 (code=1)
- 如何破除迷惘,剑锋直指苍穹
- 【UISegmentedControl】
- 欢迎使用CSDN-markdown编辑器
- 【DirectX 2D游戏编程基础】DirectX环境的搭建
- ssh2
- ggplot2——饼图篇
- pip的安装,更新,卸载模块以及使用方法 python
- linux mmap 映射文件
- zeromq-4.1.2在windows下的编译
- 学习JS(5)