简体   繁体   中英

iOS 8 Black background instead of transparent cell background

I am creating custom selection style for cell. I removed all background colors and made them transparent and after that I changed colors of labels and others things what I need. The problem is that sometimes in iOS 8 with iPhone 5S I get black background when cell is selected. I have this information from real device and I have screens. On other devices it looks that it's working (but I am not sure). The problem is that when I tried to view this in emulator it shows this problem just few times from many attempts (something like one from 20 times).

The problem looks is in line with setting selectedBackgroundView from image with clear color. I was looking everywhere else and I think the problem isn't elsewhere. Could be problem with image with clearColor? How would you fix it? How to test it without real device?

// 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];

Edit: I read my post again I didn't say that I have iPhone 5 (iOS 8) in which I test this app and it looks ok and I know that in iPhone 4 it is working without problem too. I can say which devices are working and which not. I know about these 3.

Try to replace [UIColor clearColor] with [UIColor colorWithWhite:0 alpha:0]. I noticed that sometimes "clear color" does not contain proper alpha value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM