UIColor colorWithPatternImage:UITableView的separatorColor中的透明度问题

Dri*_*met 11 user-interface objective-c uicolor ios ios5

设置我的图案我有麻烦UIColor.在iOS 5中它一切都很好,但在iOS 4.3中我遇到了问题.我添加了一个图像以便更好地理解.我已经谷歌搜索了一下,发现答案可能是opaque属性的设置NO.但我已经设置每隔view,contentView,backgroundView,tableViewCell它的opaque价值NO.

您可以看到分隔符颜色为黑色,其中图像具有透明度

您可以看到分隔符颜色为黑色,其中图像具有透明度

Pau*_*ott 18

这似乎是iOS 4.3中的一个错误,它在5.0中修复.

为了使这在4.3上工作,在将视图的backgroundColor设置为模式图像之后,您需要将视图和图层都设置为非不透明,如下所示:

UIImage* pattern = [UIImage imageNamed:@"translucentPatternImage.png"];
view.backgroundColor = [UIColor colorWithPatternImage:pattern];
[view.layer setOpaque:NO];
view.opaque = NO;
Run Code Online (Sandbox Code Playgroud)

  • 似乎这在iOS 6中不起作用. (2认同)

Sco*_*ood 0

如果我没记错的话,您必须设置 TableViewCell 中标签的背景颜色。所以像,

[cell.textLabel setBackgroundColor:[UIColor clearColor]];