在今天发布的 iOS 5.1 GM 中测试我的应用程序时,我注意到我的一些视图绘制的是纯黑色而不是图案背景色。完全相同的代码在以前的 iOS 版本上运行良好(在 4.2 - 5.0.1 上测试)。
See screenshots:
![Screenshots of issue](https://i.stack.imgur.com/J302g.png)
还有其他人经历过这个吗?有解决方法吗?
回答我自己的问题(我花了几天时间来调试这个,所以希望这可以节省其他人的时间;)):
根本原因涉及使用图案化的 UIColor(通过+[UIColor colorWithPatternImage:]
) 作为具有相同图像的 UIImageView 上方 UIView 的背景颜色。
Example:
UIImageView *imageView = [[UIImageView alloc] initWithImage:anImage];
[_containerView addSubview:imageView];
UIColor *patternColor = [UIColor colorWithPatternImage:anImage];
UIView *patternView = [[UIView alloc] initWithFrame:frame];
[patternView setBackgroundColor:patternColor];
[_containerView addSubview:patternView];
两个视图都绘制为黑色,并且似乎存在缓存问题,图像的所有其他用途都绘制为黑色,直到应用程序暂停/恢复为止。
我向 Apple 提交了问题 #10795514 来报告此问题,但看起来它已进入 5.1。可以在以下位置减少此问题:http://iccir.com/public/radar/Radar10795514.zip
我发现的唯一解决方法是展平视图层次结构并在同一视图中绘制图案图像两次。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)