UIView -> image & 本地时间获取

//UIView 转换为图片

UIGraphicsBeginImageContext(self.rootsView.bounds.size);

[_rootsView.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *viewBeImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return viewBeImage;

//本地时间

NSDate *now = [NSDate date];
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSUInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
    NSDateComponents *dateComponent = [calendar components:unitFlags fromDate:now];
    NSInteger year = [dateComponent year];//年
     NSInteger month = [dateComponent month];//月
     NSInteger day = [dateComponent day];//日
    NSInteger hour = [dateComponent hour];//小时
    NSInteger minute = [dateComponent minute];//分钟
    NSInteger second = [dateComponent second];//秒钟
    NSLog(@"year is: %ld", year);
    NSLog(@"month is: %ld", month);
    NSLog(@"day is: %ld", day);
    NSLog(@"hour is: %ld", hour);
    NSLog(@"minute is: %ld", minute);
    NSLog(@"second is: %ld", second);

posted @ 2015-12-30 11:30  V清风  阅读(260)  评论(0编辑  收藏  举报