1

我参考该网站在 iOS 5 上模糊图像:

关联

该网站提供了很多方法来模糊图像

最后我用

- (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur;

模糊图像。

它在 iOS 6 上运行良好,但在 iOS 5 上遇到问题

问题发生在

CGContextRef ctx = CGBitmapContextCreate(
                                outBuffer.data,
                                outBuffer.width,
                                outBuffer.height,
                                8,
                                outBuffer.rowBytes,
                                colorSpace,
                                kCGImageAlphaNoneSkipLast);

ctx 为 nil,错误消息为:

<Error>: CGBitmapContextCreate: invalid data bytes/row: should be at least 2560 for 8 integer bits/component, 3 components, kCGImageAlphaNoneSkipLast.

那什么意识?

4

2 回答 2

0

查看出色的 Nick Lockwood 的 FXBlurView - 它让 iOS 7 像 iOS 5 及更高版本一样模糊

FXBlurView

于 2013-09-25T09:20:05.813 回答
0

您可以使用UIVisualEffectView,或者如果您想要更多控制,您可以使用 Apple 的UIImageEffects示例代码。

这是 iOS 开发人员库上的示例代码:模糊和着色图像

以下是如何使用它:

#import "UIImageEffects.h"
...

self.originalImageView.image = [UIImageEffects imageByApplyingLightEffectToImage:[UIImage imageNamed:@"yourImage.png"]];
于 2016-02-04T16:23:29.100 回答