我正在尝试在名为srcView的UIView实例上添加过滤器视图。我正在做的事情如下:
//Generate the screenshot of srcView
UIGraphicsBeginImageContext(srcView.bounds.size);
[srcView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imageData = UIImageJPEGRepresentation(image, 1); // convert to jpeg
image = [UIImage imageWithData:imageData];
//A custom filter effect applied on a image
imageView.image = [image boxblurImageWithBlur:kStyleBlur];
工作正常。但是当设备旋转时,由于srcView将重新发布其子视图,我正在做的是在设备旋转(UIApplicationDidChangeStatusBarOrientationNotification
)后重新生成srcView的屏幕截图,因此imageView似乎“跳”了一点。有没有办法避免它'跳'?
答案 0 :(得分:0)
你愿意实施动画吗? 你可以尝试:
CGAffineTransform transform = CGAffineTransformMakeRotation(3.14159/2);
imageView.transform = transform;
// Repositions and resizes the imageview.
CGRect contentRect = //the new rect
imageView.bounds = contentRect;