UIAlertController
2015-12-30 11:02
459 查看
UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:nilmessage:title
preferredStyle:UIAlertControllerStyleAlert];
/**设置 textField
的暗文 */
[alertControlleraddTextFieldWithConfigurationHandler:^(UITextField *_Nonnull
textField) {
textField.placeholder =@"密码";
textField.secureTextEntry =YES;
}];
/**设置 alertController的按钮*/
UIAlertAction *cancelAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
UIAlertAction *okAction = [UIAlertActionactionWithTitle:@"确认"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction
*_Nonnull action) {
UITextField *login = alertController.textFields.firstObject;
if ([login.textisEqualToString:@"123"])
{
NSLog(@"成功");
}else{
UIView * view = [[UIApplicationsharedApplication].windowslastObject];
[selfshowMBProgressHUDWith:view
labelText:@"密码错误,请重试"andHidenTime:1];
}
}];
/**设置 UIAlertAction的字体颜色 */
[cancelActionsetValue:NAVCOLORforKey:@"_titleTextColor"];
[okActionsetValue:NAVCOLORforKey:@"_titleTextColor"];
[alertControlleraddAction:cancelAction];
[alertControlleraddAction:okAction];
/**弹出 alertController */
[selfpresentViewController:alertController
animated:YEScompletion:nil];
preferredStyle:UIAlertControllerStyleAlert];
/**设置 textField
的暗文 */
[alertControlleraddTextFieldWithConfigurationHandler:^(UITextField *_Nonnull
textField) {
textField.placeholder =@"密码";
textField.secureTextEntry =YES;
}];
/**设置 alertController的按钮*/
UIAlertAction *cancelAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
UIAlertAction *okAction = [UIAlertActionactionWithTitle:@"确认"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction
*_Nonnull action) {
UITextField *login = alertController.textFields.firstObject;
if ([login.textisEqualToString:@"123"])
{
NSLog(@"成功");
}else{
UIView * view = [[UIApplicationsharedApplication].windowslastObject];
[selfshowMBProgressHUDWith:view
labelText:@"密码错误,请重试"andHidenTime:1];
}
}];
/**设置 UIAlertAction的字体颜色 */
[cancelActionsetValue:NAVCOLORforKey:@"_titleTextColor"];
[okActionsetValue:NAVCOLORforKey:@"_titleTextColor"];
[alertControlleraddAction:cancelAction];
[alertControlleraddAction:okAction];
/**弹出 alertController */
[selfpresentViewController:alertController
animated:YEScompletion:nil];
相关文章推荐
- 如何使用 Cloud Insight SDK 实现 Druid 监控?
- 关于UILabel产生黑边的原因及去除方法
- 如何得到iPhone手机的UUID
- checking host system type... configure: error: can not guess host type; you must specify one
- 如何使用 Cloud Insight SDK 实现 Druid 监控?
- Leetcode: Range Sum Query - Immutable
- 黑马程序员--OC自学笔记---10Foundation、NSFileManager、iOS沙盒、OC结构体、NSNumber、NSValue、NSDate、copy、单例模式
- Leetcode: Range Sum Query 2D - Immutable
- UIControl的介绍和使用
- CALayer与UIView的关系
- UpdateData(TRUE)和UpdateData(FALSE)的区别
- java.sql.SQLException:Column count doesn't match value count at row 1
- iOS 通过HEX(十六进制)得到一个UIColor的对象
- 虚拟环境下使用fuel安装部署opesntack
- UGUI中Button和Toggle 添加动态事件
- 在一个UILabel的文字采用不同的字体样式和字体大小
- UISwitch详解
- beginUpdates和endUpdates-实现UITableView的动画块
- MiniUI——TreeGrid懒加载
- easyui中 在子tabs中 添加新的tabs