国产探花免费观看_亚洲丰满少妇自慰呻吟_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架構淺解

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 黔西| 沙湾县| 驻马店市| 腾冲县| 榕江县| 嵩明县| 江津市| 兴山县| 留坝县| 榆社县| 永年县| 安阳市| 西充县| 永泰县| 河池市| 祁东县| 齐齐哈尔市| 宁津县| 德惠市| 綦江县| 呼和浩特市| 丽江市| 阿拉善右旗| 白朗县| 威宁| 双鸭山市| 沐川县| 边坝县| 密山市| 民乐县| 那坡县| 禄丰县| 霸州市| 木里| 丰镇市| 呼玛县| 昌平区| 兴宁市| 抚顺县| 交口县| 枞阳县|