gpt4 book ai didi

ios - 提高模糊性能 iOS7/8

转载 作者:行者123 更新时间:2023-11-29 02:47:27 24 4
gpt4 key购买 nike

这是模糊 View 的最快方法吗 - 因为对于我的 View (图像的 UICollectionView)来说,它对于良好的 UX 来说太慢了 - 任何关于性能改进的提示,更好的方法?

我尝试改变 BeginImageContext 方法(第三个变量)的比例,性能几乎没有变化。

(import category on UIImage from Apple)
#UIImage+ImageEffects.h

- (UIImage*)blurViewToImage:(UIView *)view type:(int)type {

//0 -dark
//1 -light
//2 -extra light

UIGraphicsBeginImageContextWithOptions(view.frame.size, true, 0.0f);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:false];
UIImage * snappy = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

switch (type) {
case 0:
return [snappy applyDarkEffect];
break;
case 1:
return [snappy applyLightEffect];
break;
case 2:
return [snappy applyExtraLightEffect];
break;
default:
break;
}

return nil;
}

最佳答案

您可能想看看 this on StackOverflow

如果这不能满足您的需要,请尝试调用该函数

- (UIImage*)blurViewToImage:(UIView *)view type:(int)type

在一个单独的线程中,因此您的 UI 保持可用:

[self performSelectorInBackground:(SEL) withObject:(id)]

关于ios - 提高模糊性能 iOS7/8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24937254/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com