OC-UIAlertController& UIStepper& UISlider& UISwitch
2016-09-02 20:21
513 查看
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]; }
相关文章推荐
- iOS开发-Day27UISwitch&UISlider&UIStepper&UISegmentedControl
- OC-UICollectionViewController& UITabBarController
- UISwitch、UISlider、UISegmentedControl、UIActivityIndicatorView、UIStepper、UIProgress、UIAlertView--(图)
- UI控件笔记(八):UI之UISlider\UIStepper\ UIProgressView\ UITextView\UISwitch\ UIActivityIndicatorView\ UISeg
- IOS笔记之UIKit_UISlider/UIStepper/UISwitch
- IOS代码实现常用控件UIButton、UISlider、UISwitch、UISegmentedControl
- UIAlertView与[UIApplication sharedApplication].keyWindow.rootViewController的冲突解决
- UI 15 UITableViewController & 系统自带快捷菜单 & 系统下拉刷新
- IOS代码实现常用控件UIButton、UISlider、UISwitch、UISegmentedControl
- 【IOS 开发学习总结-OC-47】★ios开发之UI控件——UIAlertView与 UIActionSheet
- IOS代码实现常用控件UIButton、UISlider、UISwitch、UISegmentedControl
- 【iOS学习笔记】代码实现常用控件UIButton、UISlider、UISwitch、UISegmentedControl
- 【IOS 开发学习总结-OC-46】★ios开发之UI控件——UIProgressView 与 UISlider(另:可拉伸图片)
- iosui学习中的课堂笔记 UISegmentedControl。UISlider。UIStepper。UISwitch。
- UISlider/UISegmentedControl/UISetpper/UISwitch/UIProgressView/UIPageControl
- IOS代码实现常用控件UIButton、UISlider、UISwitch、UISegmentedControl
- iOS UISplitViewController 开发(iOS8)
- Android UI设计之<二>自定义SwitchButton开关,实现类似IOS中UISwitch的动画效果
- 11、UISwitch-OC+UI
- 10、UISlider-OC+UI