国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS 生日選擇器

2019-11-06 10:01:44
字體:
來源:轉載
供稿:網友
////  ViewController.m//  test////  Created by 王小勝 on 2017/2/27.//  Copyright © 2017年 王小勝. All rights reserved.//#import "ViewController.h"@interface ViewController ()@PRoperty (nonatomic,strong)UILabel *birthDay;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    [self.view setBackgroundColor:[UIColor whiteColor]];    //lable    UILabel *birthDay = [[UILabel alloc]initWithFrame:CGRectMake(100, 200, 150, 35)];    birthDay.text = @"生日";        //按鈕    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(145, 250, 40, 35)];    self.birthDay = birthDay;    btn.backgroundColor = [UIColor greenColor];    btn.layer.cornerRadius = 10;    btn.layer.masksToBounds = YES;        [btn addTarget:self action:@selector(action) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:btn];    [self.view addSubview:birthDay];}-(void)action {    UIDatePicker *datePicker = [[UIDatePicker alloc] init]; datePicker.datePickerMode = UIDatePickerModeDate;        NSLocale *local = [[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"];//設置為中    datePicker.locale = local;        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"/n/n/n/n/n/n/n/n/n" message:nil preferredStyle:UIAlertControllerStyleActionSheet];    [alert.view addSubview:datePicker];        UIAlertAction *ok = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {                NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];                //實例化一個NSDateFormatter對象                [dateFormat setDateFormat:@"yyyy年MM月dd日"];//設定時間格式                NSString *dateString = [dateFormat stringFromDate:datePicker.date];                //求出當天的時間字符串        self.birthDay.text = dateString;    }];        [alert addAction:ok];    [self presentViewController:alert animated:YES completion:^{ }];}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}@end


上一篇:iOS 之清理緩存

下一篇:iOS架構淺解

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永川市| 顺昌县| 茌平县| 镇雄县| 永安市| 汕尾市| 佛学| 红河县| 常州市| 阿勒泰市| 土默特右旗| 平塘县| 曲沃县| 通榆县| 玉龙| 礼泉县| 徐闻县| 津市市| 大新县| 防城港市| 芜湖县| 农安县| 米脂县| 临夏县| 东阳市| 花莲市| 临江市| 台湾省| 凌源市| 新余市| 渑池县| 黄冈市| 斗六市| 商丘市| 正镶白旗| 迁安市| 怀安县| 图们市| 兰州市| 迭部县| 汉川市|