我在设置图案化的UIColor
时遇到麻烦。在iOS 5中,一切都很好,但是在iOS 4.3中,我遇到了问题。我添加了一个图像,以更好地理解。我已经用Google搜索了一下,发现答案可能是opaque
属性设置为NO
。但是我已经将每个view
,contentView
,backgroundView
和tableViewCell
都设置为opaque
的NO
值。
您会看到分隔符颜色为黑色,图案的图像具有透明性
最佳答案
这似乎是iOS 4.3中的错误,已在5.0中修复。
为了使此功能在4.3上有效,您需要在将 View 的backgroundColor设置为图案图像后,将 View 和层都设置为为不透明,如下所示:
UIImage* pattern = [UIImage imageNamed:@"translucentPatternImage.png"];
view.backgroundColor = [UIColor colorWithPatternImage:pattern];
[view.layer setOpaque:NO];
view.opaque = NO;