UISlider UISegment UISwitch UIStepper UIAlert

UISlider

1.初始化

  UISlider *slider = [UISlider alloc] initWithFrame:CGRectMake(,,,)];

2.点击事件

  slider addTarget:self action:@selector(click:) forControlEvents:UIControlEventValueChanged];

   //当尺子记录的值发生的改变,会触发方法

3.在滑动过程中是否触发事件

   slider.continuous = NO;

4.设置滑尺最大和最小的记录(默认是0~1)

   slider.minimumValue = 10;

   slider.maximumValue = 100;

5.修改滑尺上线条的颜色

   slider.minimumTrackTintColor = [UIColor redColor];

   slider.maximumTrackTintColor = [];

6.设置圆圈的图片

    slider setThumbImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];

 

 

 

 

UISegment

1.初始化

   UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"",@"",[UIImage imageNamed:@""],nil]];

//使用一个数组初始化一个选择器,数组里可以放字符串和图片(图片只取形状,不取颜色),实际应用中,一般都是要么都用字符串,要么都用图片

2.设置颜色

  segment.tintColor = [UIColor redColor];

3.删除一个选择

   [segment removeSegmentAtIndex:2 animated:YES];

4.插入一个选择

   [segment insertSegmentWithTitle:@"" atIndex:1 animated:YES];

5.设置被选中的分段

   segment.selectedSegmentIndex = 1;

6.点击事件

   segment addTarget:self action:@selector(segmentClick:) forControlEvents:UIControlEventValueChanged];

7.- (void)segmentClick:(UISegmentedControl *)sender{  NSInteger index = sender.selectedSegmentIndex;}

 

 

 

UISwitch

1.初始化
  UISwitch *sw = [[UISwitch alloc] initWithframe:CGRectMake(,,,)];//大小是51*31,固定的

2.设置打开状态,关闭状态和圆圈的颜色

   sw.onTintColor = [UIColor redColor];

   sw.tintColor = [UIColor blackColor];

   sw.thumbTintColor = [UIColor greenColor];

3.开关状态

   sw.on = YES;

4.开关的事件

  sw addTarget:self action:@selector(swClick:) forControlEvents:UIControlEventValueChanged];

 

 

 

 

UIActivityIndicatiorView活动指示器

1.初始化

   UIActivityIndicatorView *aiv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

2.显示在屏幕的正中间

   aiv.center = self.view.center;

3.改变颜色

   aiv.color = [];

4.开始活动

   [aiv startAnimating];

 

 

 

UIWebView

1.初始化

   UIWevView *wv = [[UIWebView alloc] initWithFrame:self.view.bounds];

2.将一个字符串转化成网址类的对象

   NSString *urlStr = @"";

   NSURL *url = [NSURL URLWithString:urlStr];

3.使用一个网络链接创建一个网络请求

   NSURLRequest *request = [NSURLRequest requestWithURL:url];

4.网页视图开始加载网络请求

   [wv loadRequest:request];

 

 

 

 

 

UIStepper

1.初始化

   UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(,,,)];//大小是固定的

2.设置颜色

   stepper.tintColor = [UIColor redColor];

3.设置步长,一次加减的值

   stepper.stepValue = 40;

4.最小和最大值

   stepper.minimumValue = 10;

   stepper.maximumValue = 300;

5.设置加号和减号的图片(只取形状,不取颜色)

  [stepper setIncrementImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];

  [stepper setDecrementImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];

 

 

 

UIProgress

1.UIProgressView *pv = [[UIProgressView alloc] initWithFrame:CGRectMake(,,,)];

2.设置进度

   pv.progress = 0.5;

3.进度条左边和右边的颜色

   pv.progressTintColor = [UIColor redColor];

   pv.trackTintColor = [UIColor greenColor];

 

UIAlert

1.初始化
   UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"通知" message:@"电量不足,是否充电" delegate:self cancelButtonTitle:@"no" otherButtonTitles:@"yes",@"oye", nil];

    [av show];//让警告框显示在controller中

2.//警告框的点击事件
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
    NSLog(@"%ld==%ld", alertView.tag, buttonIndex);
    //在实际工作中,如果有多个警告框需要点击事件,那么得用alertView.tag来判断点击的是哪一个警告框,然后用buttonIndex判断点击的是  哪一个按钮
      }

 

 

UIActionSheet

1.UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:@"分享到" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"朋友圈" otherButtonTitles:@"微信好友",@"qq空间",@"qq好友",@"微博", nil];

  [as showInView:self.view];

2.//actionSheet的点击事件
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSLog(@"%ld======%ld",actionSheet.tag,buttonIndex);
    //如果有多个as,得用tag值区分点击的是哪一个as,然后用下标判断点击的是哪一个按钮
}

转载于:https://www.cnblogs.com/Angelone/p/4386981.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值