【问题标题】:iOS 8 Black background instead of transparent cell backgroundiOS 8 黑色背景而不是透明单元格背景
【发布时间】:2014-10-23 06:44:30
【问题描述】:

我正在为单元格创建自定义选择样式。我删除了所有背景颜色并使它们透明,然后我更改了标签的颜色和其他我需要的东西。 The problem is that sometimes in iOS 8 with iPhone 5S I get black background when cell is selected.我有来自真实设备的这些信息,我有屏幕。在其他设备上看起来它正在工作(但我不确定)。问题是,当我尝试在模拟器中查看它时,它在多次尝试中仅显示了几次此问题(类似于 20 次中的一次)。

问题看起来与从具有清晰颜色的图像中设置 selectedBackgroundView 一致。我一直在寻找其他地方,我认为问题不在其他地方。 clearColor 的图像可能有问题吗?你会如何解决它?如何在没有真机的情况下进行测试?

// Make default subviews transparent in case someone decides to use them.
    self.textLabel.backgroundColor = [UIColor clearColor];
    self.detailTextLabel.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    self.backgroundColor = [UIColor clearColor];
    self.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageWithColor:[UIColor clearColor]]];
    self.selectedBackgroundView.tintColor = [UIColor clearColor];

编辑:我再次阅读了我的帖子,我没有说我有 iPhone 5 (iOS 8),我在其中测试了这个应用程序,它看起来不错,我知道在 iPhone 4 中它也可以正常工作。我可以说哪些设备在工作,哪些不工作。这三个我都知道。

【问题讨论】:

  • 您是在故事板中工作还是只在代码中工作? 只有一个单元格吗?
  • 只有一个单元格类(MenuCell)。上面的代码是在 awakeFromNib 函数中设置的,在 Storyboard 中我只是设置了视图和插座。

标签: ios objective-c uiimageview ios8 transparency


【解决方案1】:

尝试将 [UIColor clearColor] 替换为 [UIColor colorWithWhite:0 alpha:0]。我注意到有时“清晰的颜色”不包含正确的 alpha 值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-06
    • 2015-04-01
    • 2013-09-21
    • 1970-01-01
    • 2015-10-03
    • 2012-02-17
    • 1970-01-01
    • 2016-02-22
    相关资源
    最近更新 更多