UI中常用的控件Slider\SegmentCtrl\PageCtrl
来源:互联网 发布:建筑工程造价软件 编辑:程序博客网 时间:2024/05/23 23:30
- (void)viewDidLoad {
[superviewDidLoad];
//创建滑块
//滑块不能滑动:(1)高度为0;(2)最值设置反了
UISlider *slider = [[UISlideralloc] initWithFrame:CGRectMake(90,90, 200, 20)];
//设置最大值和最小值
slider.maximumValue =10;
slider.minimumValue =0;
//设置初始值
slider.value =5.0;
UIImage *img1 = [UIImageimageNamed:@"com_thumb_max_n-Decoded"];
//设置滑块图片
[slider setThumbImage:img1forState:UIControlStateNormal];
UIImage *img2 = [UIImageimageNamed:@"com_thumb_max_h-Decoded"];
[slider setThumbImage:img2forState:UIControlStateHighlighted];
//设置滑条左右的颜色
// [slider setMinimumTrackTintColor:[UIColor purpleColor]];
// [slider setMaximumTrackTintColor:[UIColor greenColor]];
UIImage *minImg = [UIImageimageNamed:@"com_slider_min_l-Decoded"];
UIImage *maxImg = [UIImageimageNamed:@"com_slider_max_l-Decoded"];
//设置图片的拉伸点
minImg = [minImg stretchableImageWithLeftCapWidth:10topCapHeight:0];
maxImg = [maxImg stretchableImageWithLeftCapWidth:10topCapHeight:0];
//设置左右两侧显示的图片
[slider setMinimumTrackImage:minImgforState:UIControlStateNormal];
[slider setMaximumTrackImage:maxImgforState:UIControlStateNormal];
//添加事件
[slider addTarget:selfaction:@selector(sliderAction:)forControlEvents:UIControlEventValueChanged];
[self.viewaddSubview:slider];
[sliderrelease];
}
//SegmentionCtrl
- (void)viewDidLoad {
[superviewDidLoad];
NSArray *items =@[@"电影",@"动漫",@"综艺",@"电视剧"];
//分段控件
UISegmentedControl *segCtrl = [[UISegmentedControlalloc] initWithItems:items];
segCtrl.frame =CGRectMake(90,90, 190, 40);
//设置初始选项
segCtrl.selectedSegmentIndex =0;
//设置显示的样式,在iOS8弃用了
// segCtrl.segmentedControlStyle = UISegmentedControlStyleBezeled;
//设置颜色
// segCtrl.tintColor = [UIColor redColor];
//添加事件
[segCtrl addTarget:selfaction:@selector(segAction:)forControlEvents:UIControlEventValueChanged];
[self.viewaddSubview:segCtrl];
[segCtrlrelease];
[self_initViews];
}
//加载提示图标
- (void)_initViews {
self.view.backgroundColor = [UIColororangeColor];
//使用系统的加载提示
UIApplication *app = [UIApplicationsharedApplication];
[app setNetworkActivityIndicatorVisible:YES];
//使用自定义的
UIActivityIndicatorView *indicatorView = [[UIActivityIndicatorViewalloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicatorView.frame =CGRectMake(100,200, 90, 90);
//开始转动
[indicatorViewstartAnimating];
//延迟3秒停止
[indicatorViewperformSelector:@selector(stopAnimating)withObject:nilafterDelay:3];
[self.viewaddSubview:indicatorView];
[indicatorViewrelease];
}
- (void)segAction:(UISegmentedControl *)seg {
NSLog(@"%d",seg.selectedSegmentIndex);
}
- (void)viewDidLoad {
[superviewDidLoad];
self.view.backgroundColor = [UIColororangeColor];
UIPageControl *pageCtrl = [[UIPageControlalloc] initWithFrame:CGRectMake(90,90, 200, 30)];
//设置页数
pageCtrl.numberOfPages =5;
//设置初始值
pageCtrl.currentPage =3;
//设置未选中的图标的颜色
// pageCtrl.pageIndicatorTintColor = [UIColor redColor];
//添加点击事件
[pageCtrl addTarget:selfaction:@selector(pageAction:)forControlEvents:UIControlEventValueChanged];
[self.viewaddSubview:pageCtrl];
}
- (void)pageAction:(UIPageControl *)pg {
// NSLog(@"%ld",pg.currentPage);
/*-----------------提示框-------------*/
UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@"标题"message:@"信息"delegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"确定",nil];
//设置提示框的样式
alertView.alertViewStyle =UIAlertViewStyleLoginAndPasswordInput;
[alertViewshow];
}
#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"%ld",buttonIndex);
if (buttonIndex == 0) {
NSLog(@"取消");
}elseif (buttonIndex == 1) {
NSLog(@"确定");
}
//取得输入框的信息
UITextField *textField1 = [alertView textFieldAtIndex:0];
UITextField *textField2 = [alertView textFieldAtIndex:1];
NSLog(@"登陆名:%@密码:%@",textField1.text,textField2.text);
}
- UI中常用的控件Slider\SegmentCtrl\PageCtrl
- jQuery UI 控件之Slider
- vc中滑动控件slider的使用
- VC++中slider控件的使用
- Android中常用的UI控件
- Android中常用的UI控件
- UI中常用的控件ImageView\Button
- Slider控件的使用方法
- iPhone开发【五】常用控件之Slider(不使用xib构建UI)
- iPhone开发【五】常用控件之Slider(不使用xib构建UI)
- MFC中 滑动条控件 Slider Control 的添加
- OC 中常用UI控件的简单设置
- UI中一些控件的不常用方法
- IOS常用的UI控件
- iOS—UI-手势及控件(segment switch slider)的使用
- Ext.slider控件的用法
- UI中最常用的三大控件的常用属性
- Slider控件
- 力所能及之hibernate简单的增删查改
- 开源游戏引擎详解
- 6、R语言,调用自编函数
- 给定字符串,求出现次数最多的那个字母及次数,如有多个重复则都输出
- 流媒体一
- UI中常用的控件Slider\SegmentCtrl\PageCtrl
- URAL 2012. About Grisha N.
- poj 3070(矩阵快速幂)
- live555类关系图
- 02引言-AngularJS基础教程
- Codeforces Round #296 (Div. 2) C(STL_set)
- Mac下/usr/include缺失
- js闭包
- nginx和apache设置不缓存文件