0

我正在尝试在名为 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 似乎有点“跳跃”。有没有办法避免它“跳跃”?

4

1 回答 1

0

你愿意实现动画吗?你可以试试:

CGAffineTransform transform = CGAffineTransformMakeRotation(3.14159/2);
imageView.transform = transform;

// Repositions and resizes the imageview.
CGRect contentRect = //the new rect
imageView.bounds = contentRect;
于 2013-02-15T15:04:32.540 回答