tripsters2019@163.com
tripsters2019@163.com
  • 发布:4 天前
  • 更新:4 天前
  • 阅读:35

求个大佬帮忙用5+plus翻译一下这段IOS原生代码

分类:Native.js
- (void)viewDidLoad {  
    [super viewDidLoad];  
    // Do any additional setup after loading the view.‘  
    self.view.backgroundColor = [UIColor orangeColor];  

    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 80, self.view.frame.size.width, 216)];  
    self.datePicker.datePickerMode = UIDatePickerModeDate;  
    self.datePicker.backgroundColor = [UIColor groupTableViewBackgroundColor];  
    [self.view addSubview:self.datePicker];  

    [self.datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged ];//重点:UIControlEventValueChanged  

    //设置显示格式  
    //默认根据手机本地设置显示为中文还是其他语言  
    NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//设置为中文显示  
    self.datePicker.locale = locale;  

    //当前时间创建NSDate  
    NSDate *localDate = [NSDate date];  
    //在当前时间加上的时间:格里高利历  
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];  
    NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];  
    //设置时间  
    [offsetComponents setYear:0];  
    [offsetComponents setMonth:0];  
    [offsetComponents setDay:5];  
    [offsetComponents setHour:20];  
    [offsetComponents setMinute:0];  
    [offsetComponents setSecond:0];  
    //设置最大值时间  
    NSDate *maxDate = [gregorian dateByAddingComponents:offsetComponents toDate:localDate options:0];  
    //设置属性  
    self.datePicker.minimumDate = localDate;  
    self.datePicker.maximumDate = maxDate;  

    _showLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.datePicker.frame)+20, CGRectGetWidth(self.datePicker.frame), 30)];  
    _showLabel.backgroundColor = [UIColor groupTableViewBackgroundColor];  
    _showLabel.textAlignment = NSTextAlignmentCenter;  
    _showLabel.text = @"显示获取的日期时间";  
    [self.view addSubview:_showLabel];  

}
4 天前 负责人:无 分享
已邀请:

要回复问题请先登录注册