使用UIImages applyBlurWithRadius并冻结我的应用程序约5秒钟?

时间:2014-07-10 15:30:40

标签: ios objective-c ios7 uiimage

我正在使用UIIamges applyBlurWithRadius方法,但它会冻结我的应用程序约5秒钟。为什么这种方法如此记忆,还有其他选择吗?总的来说,我试图让UIImage模糊它然后将它变成alpha。

- (IBAction)updateImage:(id)sender
{
UIImage *effectImage = nil;
UIColor *tintColor = [UIColor colorWithWhite:0.97 alpha:0.62];
effectImage = [self.image applyBlurWithRadius:13 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];

if(!Is_iPad){

    effectImage = [UIImage imageWithCGImage:[effectImage CGImage] scale:1.0f orientation:UIImageOrientationRight];

}

self.bgImageView.image = effectImage;


}

////更新//////

我添加了这个去除冻结,但是当VC加载图像时会加载常规,然后在5秒后最终显示模糊图像(即,当applyBlurWithRadius完成处理时)。

- (IBAction)updateImage:(id)sender
{
__block UIImage *effectImage = nil;

dispatch_async(dispatch_queue_create("com.stat.completionQueue", NULL), ^{

    UIColor *tintColor = [UIColor colorWithWhite:0.97 alpha:0.62];
    effectImage = [self.image applyBlurWithRadius:13 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];

    if(!Is_iPad){
        effectImage = [UIImage imageWithCGImage:[effectImage CGImage] scale:1.0f orientation:UIImageOrientationRight];
    }

    dispatch_async(dispatch_get_main_queue(), ^{
        self.bgImageView.image = effectImage;
    });
});
}

0 个答案:

没有答案