博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
几种常用控件的使用方法
阅读量:4310 次
发布时间:2019-06-06

本文共 2035 字,大约阅读时间需要 6 分钟。

1.UIActivityIndicatorView的使用

 

 UIActivityIndicatorView *activity=[[[UIActivityIndicatorViewalloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]autorelease];

z

    [activity setFrame:CGRectMake(150,150, 50, 50)];

    [self.window addSubview:activity];    

    [activity startAnimating];

2. UISlider的使用

 

    UISlider *slider=[[[UISlideralloc] initWithFrame:CGRectMake(100,20, 140,20)] autorelease];

    slider.maximumValue=10;

    slider.value=5;

    [slider addTarget:selfaction:@selector(change:)forControlEvents:UIControlEventTouchUpInside];

    [self.window addSubview:slider];

-(void)change:(UISlider*)slider

{

    NSLog(@"the val is %.2f",slider.value);

}

3.UIPageControl

通常与UIScrollView连用,提示用户当前显示的页数

 

@property(nonatomic) NSInteger numberOfPages;          // default is 0

@property(nonatomic) NSInteger currentPage;            // default is 0. value pinned to 0..numberOfPages-1

@property(nonatomic) BOOL hidesForSinglePage;          // hide the the indicator if there is only one page. default is NO

sample code:

 

UIPageControl *pageControl=[[[UIPageControl alloc] initWithFrame:CGRectMake(0, 50, 329, 30)] autorelease];    pageControl.numberOfPages=10;    pageControl.currentPage=3;    pageControl.backgroundColor=[UIColor grayColor];    [pageControl addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventValueChanged];    [self.window addSubview:pageControl];-(void)clicked:(id)sender{    UIPageControl *pageControl=(UIPageControl*)sender;    NSLog(@"curent val is %d",pageControl.currentPage);}

 

4.UISegmentedControl

 

NSArray *array=[NSArray arrayWithObjects:@"hello",@"what",@"search",nil];    UISegmentedControl *segmentControl=[[[UISegmentedControl alloc] initWithItems:array] autorelease];    segmentControl.frame=CGRectMake(0, 40, 300, 40);    segmentControl.segmentedControlStyle=UISegmentedControlStyleBordered;    segmentControl.selectedSegmentIndex=2;    [segmentControl addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventValueChanged];    [self.window addSubview:segmentControl];

 

 

 

 

 

转载于:https://www.cnblogs.com/pangblog/p/3323208.html

你可能感兴趣的文章
黑客与画家 第七章
查看>>
Tomcat实践
查看>>
第二次冲刺计划周第四天
查看>>
leetcode 120. Triangle
查看>>
边缘网关协议(BGP)
查看>>
github和gitlab并存
查看>>
表单日期点击输入时显示日历表
查看>>
Css中position、float和clear整理
查看>>
JavaScript表单验证
查看>>
Vijos p1123 均分纸牌
查看>>
关于NSDateFormatter的格式-dd是月天,DD是年天
查看>>
各路传奇排序
查看>>
像心跳的方向走
查看>>
收集JavaScript中常用的方法函数
查看>>
2. cgi 结构目录
查看>>
Abp框架下 Area中新建Layout报错的问题
查看>>
linux下修改hosts文件
查看>>
Restful API 设计参考原则
查看>>
两个实用的Python的装饰器
查看>>
将前端所要传的参数设置在一个对象中,将对象转换成字符串往后台传
查看>>