博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UI小组件学习
阅读量:5160 次
发布时间:2019-06-13

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

UIActivityIndicatorView

/*     UIActivityIndicatorViewStyleWhiteLarge,     UIActivityIndicatorViewStyleWhite,     UIActivityIndicatorViewStyleGray,     */    UIActivityIndicatorView *viView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];    viView.center=CGPointMake(160, 300);    viView.color=[UIColor blueColor];    viView.hidesWhenStopped=NO;//动画停止时是否隐藏    [viView startAnimating];//    [viView stopAnimating];//停止动画        [self.view addSubview:viView];
UIAlertView 与 UIActionSheet

UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"通知" message:@"明天礼拜五了,大家晚上多多努力,争取在放假前把项目上架。" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil,nil];       UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:@"你确定删除么?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:@"其他", nil];

 下面是各自的代理:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{    NSLog(@"点击了第%d个按键",buttonIndex);    switch (buttonIndex) {        case 0:                        break;                    default:            break;    }}- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{    NSLog(@"点击了第%d个按键",buttonIndex);    switch (buttonIndex) {        case 0:                        break;                    default:            break;    }}
UISilder

- (void)viewDidLoad{    [super viewDidLoad];    //实例化	UISlider *slide=[[UISlider alloc]initWithFrame:CGRectMake(10, 100, 300, 60)];    //设置左侧右侧轨道的图片,ios7无效    [slide setMinimumTrackImage:[UIImage imageNamed:@"max"] forState:UIControlStateNormal];    [slide setMaximumTrackImage:[UIImage imageNamed:@"min"] forState:UIControlStateNormal];        //设置最大最小值    slide.minimumValue=0;    slide.maximumValue=1;    //设置当前值    [slide setValue:0.7 animated:YES];    //添加响应函数    [slide addTarget:self action:@selector(onSliderChange:) forControlEvents:UIControlEventValueChanged];        [self.view addSubview:slide];                [self.progressView setProgress:0.7 animated:YES];    }-(void)onSliderChange:(id)sender{    NSLog(@"slider:%@",sender);    UISlider *slider=sender;    self.myView.alpha=slider.value;    self.progressLabel.text=[NSString stringWithFormat:@"%.0f%%",slider.value*100];    self.progressLabel.center=CGPointMake(20+280*slider.value, 100);    }
UISwitch

UISwitch *mySwitch=[[UISwitch alloc]initWithFrame:CGRectMake(100, 100, 200, 50)];    [mySwitch addTarget:self action:@selector(onSwitchChange:) forControlEvents:UIControlEventValueChanged];    mySwitch.onTintColor=[UIColor redColor];    mySwitch.on=NO;    [mySwitch setOn:YES animated:YES];        [self.view addSubview:mySwitch];
UITouch

#pragma mark--#pragma mark touch事件-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{        //任意取出一个touch对象    UITouch *touch = touches.anyObject;    beginPoint = [touch locationInView:self.view];    if (beginPoint.x<10) {        canMove=YES;    }else{        canMove=NO;    }    NSLog(@"触摸开始 %f,%f",beginPoint.x,beginPoint.y);}-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{        UITouch *touch = touches.anyObject;    CGPoint movePoint = [touch locationInView:self.view];    NSLog(@"触摸滑动 %f",movePoint.x-beginPoint.x);    if (canMove) {        redView.frame=CGRectMake(-320+movePoint.x-beginPoint.x, 0, 320, 480);    }    }-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{    NSLog(@"触摸结束");    UITouch *touch = touches.anyObject;    CGPoint endPoint = [touch locationInView:self.view];    if ((endPoint.x-beginPoint.x)>200) {        [UIView animateWithDuration:0.25 animations:^{            redView.frame=CGRectMake(0, 0, 320, 480);        }];            }else{        [UIView animateWithDuration:0.25 animations:^{            redView.frame=CGRectMake(-320, 0, 320, 480);        }];    }}-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{    NSLog(@"触摸取消");}

转载于:https://www.cnblogs.com/zjszyms/p/4119453.html

你可能感兴趣的文章
【转】清空mysql一个库中的所有表的数据
查看>>
基于wxPython的python代码统计工具
查看>>
淘宝JAVA中间件Diamond详解(一)---简介&快速使用
查看>>
Hadoop HBase概念学习系列之HBase里的宽表设计概念(表设计)(二十七)
查看>>
Kettle学习系列之Kettle能做什么?(三)
查看>>
Day03:Selenium,BeautifulSoup4
查看>>
awk变量
查看>>
mysql_对于DQL 的简单举例
查看>>
35. Search Insert Position(C++)
查看>>
[毕业生的商业软件开发之路]C#异常处理
查看>>
一些php文件函数
查看>>
有关快速幂取模
查看>>
Linux运维必备工具
查看>>
字符串的查找删除
查看>>
NOI2018垫底记
查看>>
快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0
查看>>
Codeforces Round #277 (Div. 2)
查看>>
【更新】智能手机批量添加联系人
查看>>
NYOJ-128前缀式计算
查看>>
深入理解 JavaScript 事件循环(一)— event loop
查看>>