UIView -> image & 本地时间获取
2015-12-30 11:30
441 查看
//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);
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);
相关文章推荐
- 如何用代码控制NGUI的点击事件
- 利用mui 实现上传图片到服务器,抛 multipart/form-data 解决方法
- iOS UITextField输入字数提示以及判断输入字体类型
- UIWindow简单介绍
- 在SOUI中非半透明窗口如何实现圆角窗口?
- IOS开发-UIView之动画效果的实现方法(一)
- Android stduio 快捷键
- UIAlertController
- 如何使用 Cloud Insight SDK 实现 Druid 监控?
- 关于UILabel产生黑边的原因及去除方法
- 如何得到iPhone手机的UUID
- checking host system type... configure: error: can not guess host type; you must specify one
- 如何使用 Cloud Insight SDK 实现 Druid 监控?
- Leetcode: Range Sum Query - Immutable
- 黑马程序员--OC自学笔记---10Foundation、NSFileManager、iOS沙盒、OC结构体、NSNumber、NSValue、NSDate、copy、单例模式
- Leetcode: Range Sum Query 2D - Immutable
- UIControl的介绍和使用
- CALayer与UIView的关系
- UpdateData(TRUE)和UpdateData(FALSE)的区别
- java.sql.SQLException:Column count doesn't match value count at row 1