OC-UIAlertController& UIStepper& UISlider& UISwitch
来源:互联网 发布:淘宝卖饰品利润怎么样 编辑:程序博客网 时间:2024/05/16 07:26
UIAlertController
警告框(AlertView 位于屏幕中间)
1.创建UIAlertController的实例,创建实例时需要制定一个style参数,将该参数写成Alert样式,则代表创建的是警告框
2.创建界面上的按键
3.将创建好的按键添加到警告框中
4.为AlertController添加文本框 (可选)
5将警告呈现出来
操作表 (ActionSheet)
1.创建UIAlertController的实例,创建实例时需要制定一个style参数,将该参数写成ActionSheet样式,则代表创建的是警告框
2.创建界面上的按键
3.将创建好的按键添加到操作表中
4.将警告呈现出来
//1.创建UIAlertController的实例,创建实例时需要制定一个style参数,将该参数写成Alert样式,则代表创建的是警告框 UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"用户名或密码错误" preferredStyle:UIAlertControllerStyleAlert]; //2.创建界面上的按键 UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]; UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"重新登录" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ NSLog(@"重新登录按键 按下"); //获取 文本框中输入的 内容 NSString *username = alert.textFields[0].text; NSString *password = alert.textFields[1].text; NSLog(@"输入的用户名是 %@ 密码是 %@",username,password); }]; UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"删除应用" style:UIAlertActionStyleDestructive handler:nil]; //3.将创建好的按键添加到警告框中 [alert addAction:action2]; [alert addAction:action1]; [alert addAction:action3]; //4.为AlertController添加文本框 [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { //参数 textField 就是我们添加的文本框实例,我们可以通过该参数对 添加的文本框的属性进行修改 textField.placeholder = @"请重新输入用户名"; }]; [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { textField.placeholder = @"请重新输入密码"; }]; //5将警告呈现出来 [self presentViewController:alert animated:YES completion:nil];
UIStepper 步进控件
作用:记录一个浮点数值,并且控件提供了两个按钮界面,由用户精确的控制记录的这个值的递增或递减
核心属性:value
核心事件:valueChanged
- (IBAction)valueChanged:(UIStepper *)sender { self.label.text = [NSString stringWithFormat:@"%.2f",sender.value];}
UISlider 滑块控件
作用: 记录一个浮点数值,通过一个可滑动的按钮,快速的在某个范围内容得到一个不容精确控制的数值
核心属性:value
核心事件:valueChanged
- (IBAction)valueChanged:(UISlider *)sender { self.label.text = [NSString stringWithFormat:@"%.2f",sender.value]; [self setupMyViewBackgroundColor];}
UISwitch开关控件
作用:记录一个布尔值,通过点击的方式,可以记录用户的是或否的选择
核心属性: on
核心事件:valueChanged
- (IBAction)valueChanged:(UISwitch *)sender { self.button.enabled = sender.on;}- (IBAction)switchButtonClick:(id)sender {// self.mySwitch.on = !self.mySwitch.on; [self.mySwitch setOn:!self.mySwitch.on animated:YES];}
0 0
- OC-UIAlertController& UIStepper& UISlider& UISwitch
- UISegmentedControll,UISlider,UISwitch,UIStepper
- UISlider、UIStepper、UISegmentControl、UISwitch、UIProgressView、UIActivityIndicatorView
- iosui学习中的课堂笔记 UISegmentedControl。UISlider。UIStepper。UISwitch。
- UISegmentedControl ,UIStepper,UISwitch,UISlider综合应用(实例需求)
- UISegmentedControl,UISlider,UISwitch,代码截屏,UIStepper的简单使用
- UISwitch、UISlider、UISegmentedControl、UIActivityIndicatorView、UIStepper、UIProgress、UIAlertView--(图)
- UISwitch / UIStepper
- UIKit基础:11.利用UISlider-UISwitch-UIStepper-UIImageView创建美女图片浏览器
- UI控件笔记(八):UI之UISlider\UIStepper\ UIProgressView\ UITextView\UISwitch\ UIActivityIndicatorView\ UISeg
- swift UISlider,UIStepper
- 27.UIStepper和UISlider
- 【学习ios之路:UI系列】ios中常见的几种控件.(UISlider,UISwitch,UIStepper,UISegmentedControl)
- 【学习ios之路:UI系列】ios中常见的几种控件.(UISlider,UISwitch,UIStepper,UISegmentedControl)
- 【学习ios之路:UI系列】ios中常见的几种控件.(UISlider,UISwitch,UIStepper,UISegmentedControl)
- UISwitch,UISlider,UIProgressView,UIActivityIndicatorView
- UISlider与UISwitch控件
- UISlider与UISwitch控件
- iOS - 设置NavigationBar的背景为透明
- 【杭电】2008 数值统计
- 网络(2):网络配置&socket编程相关的函数选项及异常处理
- myEclipse 实用技巧详解(4)
- NYOJ 925 国王的烦恼
- OC-UIAlertController& UIStepper& UISlider& UISwitch
- ou my god
- JVM类加载及执行子系统
- java程序员面试宝典笔记
- C++设计模式-AbstractFactory抽象工厂模式
- Orcl视图简单用法
- xUtils3自己努力摸索中(二)
- SLAM代码(VO简介)
- 【BZOJ】4612 [Wf2016] Forever Young