美文网首页
iOS-获取当前时间

iOS-获取当前时间

作者: Mn_Su | 来源:发表于2016-09-23 13:17 被阅读0次
             NSDate *currentDate = [NSDate date];//获取当前时间,日期
            NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
            [dateFormatter setDateFormat:@"YYYY-MM-dd"];
            NSString *dateString = [dateFormatter stringFromDate:currentDate];
            NSLog(@"dateString:%@",dateString);
            
            UILabel *timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 110 + self.picWhith + 30, WIDTH, 20)];
            timeLabel.text = dateString;
            timeLabel.textAlignment = NSTextAlignmentCenter;
            timeLabel.font = [UIFont systemFontOfSize:16];
            timeLabel.textColor = WHITECOLOR;
            [self.view addSubview:timeLabel];

    相关文章

      网友评论

          本文标题:iOS-获取当前时间

          本文链接:https://www.haomeiwen.com/subject/ceutyttx.html