应用于UIView的实时文件管理器?

时间:2013-02-15 14:17:53

标签: ios uiview filter core-image

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

1 个答案:

答案 0 :(得分:0)

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

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

// Repositions and resizes the imageview.
CGRect contentRect = //the new rect
imageView.bounds = contentRect;