您的位置:首页 > 产品设计 > UI/UE

蓝懿IOS新控件UIDateSpickers/UIAlertController

2016-01-14 17:40 375 查看
今天刘国斌老师讲了两个新的控件UIDateSpickers/UIAlertController,一个是日期的选择器,一个是警示窗口控制器。
一,开发使用日期时间选择器UIDatePicker的经验。UIDatePicker继承与UIControl,可以使用UIControl的方法- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents获取选择的日期时间。设置显示语言、12/24小时进制;获取本地时间,并限制选择时间的选择范围;格式化显示输出所需要的显示日期时间。

UIDatePicker *tp=[[UIDatePicker alloc]init];

// UIDatePickerModeDateAndTime 枚举值是2,一般系统设置的默认属性枚举都是0,这个特殊

// UIDatePickerModeDateAndTime 是系统默认的,自己和设置的时候为这个

// tp.datePickerMode=UIDatePickerModeDateAndTime;

// 获取可以标记的样式(语言)// 指定选择器所在的区域(显示的语言)中文“zh_Hans_CN”英文“en_US”

NSLog(@"%@",[NSLocale availableLocaleIdentifiers]);

tp.locale=[NSLocale localeWithLocaleIdentifier:@"bj_cn"];

// ************ 计时器 ****************

tp.datePickerMode=UIDatePickerModeCountDownTimer;

// 倒计时持续的时间,设置时间间隔

tp.countDownDuration=60*30; // 单位:秒 /但是屏幕显示最小是分钟,所以要乘60 , 设置当当前初始的时间

tp.minuteInterval=10; // 单位:分钟

[self.view addSubview:tp];

[tp addTarget:self action:@selector(doClick) forControlEvents:UIControlEventValueChanged];

// ***********************************

self.tp=tp;

}

// 点击数值改变的时候出发的事件

-(void)doClick{

NSLog(@"呵呵");

}

-(void)moo{

// 获取的时间是天文台的时间,要再进行转换成我们自己的时间

NSLog(@"%@",self.tp.date);

};

二,

-(void)moo{

// 在 ActionSheet模式下,屏幕下方独占一行位置

UIAlertAction *okAction=[UIAlertAction actionWithTitle:@"OK"style:UIAlertActionStyleDefault handler:nil];

UIAlertAction *cancelAction=[UIAlertAction actionWithTitle:@"Cancel"style:UIAlertActionStyleCancel handler:nil];

// block

UIAlertAction *reAction=[UIAlertAction actionWithTitle:@"重新开始"style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

// ^ 是block的特征

// [self reGo];

// 这里可以直接跳转的事件方法,也可以单独封装方法写在外边在这里调用

NSLog(@"www");

}];

// 创建 UIAlertController

UIAlertController *ac=[UIAlertController alertControllerWithTitle:@"警告"message:@"提示的内容 " preferredStyle:UIAlertControllerStyleAlert];

// 添加按钮

[ac addAction:okAction];

[ac addAction:cancelAction];

[ac addAction:reAction];

// 跳转到警示窗口

[self presentViewController:ac animated:YES completion:nil];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: