这是返回image的方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
/** * 获取屏幕截图 * * @return 返回屏幕截图 */ - (UIImage *)fullScreenshots { UIWindow *window = [UIApplication sharedApplication].keyWindow; UIGraphicsBeginImageContext(window.frame.size); [window.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); // image = [UIImage imageWithCGImage:CGImageCreateWithImageInRect(image.CGImage,window.frame)]; return image; }
|
刚学发现一个直接把当前view的界面生成一个view的方法,可用来做动画效果
1 2 3 4 5 6 7 8 9 10 11
|
-(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; self.navigationController.delegate = self; //生成当前view的快照 UIView *snapShotView = [self.view snapshotViewAfterScreenUpdates:NO]; snapShotView.backgroundColor = [UIColor redColor]; snapShotView.frame = CGRectMake(0, 0, 100, 100); [self.view addSubview:snapShotView]; }
|
近期评论