iOS开发中经常用的代码片段整理

1.截图

UIGraphicsBeginImageContext(myView.bounds.size);// **** 你需要截的视图
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

2.旋转UIImage对象

UIImage *changeImage=[UIImage imageWithCGImage:oriImg.CGImage
                                             scale:1.0
                                       orientation:UIImageOrientationDown];

3.定时器立即执行

_sendTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(sendLog) userInfo:nil repeats:YES];
[_sendTimer setFireDate:[NSDate distantPast]]; // **** 立即执行

4.待续



你可能感兴趣的:(iOS开发中经常用的代码片段整理)