Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView with white background showing as Color Blended Layer in instruments and simulator

So, i have some UILabels and UITextViews in a Cell. My table was scrolling a little slow and i tried the "Color blending layers" utility available in iOS simulator and Instruments. It show in red the layers that are blending and are causing the slow scroll.

All of the elements were blending, so i put a white background to the UILabels (same as the cell) and now the UILabels are ok (they had clearColor as background before).

I did the same with the UITextViews, i selected white background, but they are still showing in screen as blending layers (colored in red).

Every UITextView configuration is done in interface builder, i tried with every option, but they still appear in red.

What do i have to do to the UITextViews so that their layers don't blend?

Thanks in advance!

PD: Sorry but i can't include captures

like image 610
saky Avatar asked Aug 16 '13 20:08

saky


2 Answers

I was struggling with this problem as well. I have a UITableView that was scrolling fine on iPhone but just jittered like crazy on the iPad. I turned on Color blending layers in Instruments and, like you said, it appears opaque = YES; and backgroundColor = [UIColor whiteColor]; have no effect.

Bob is correct too, UILabels are more performant. However my implementation relies on exclusion paths, which are only available in UITextView because of the exposed TextKit stack. I couldn't just use UILabel so out of desperation I tried this and the red on my UITextViews disappeared:

for (UIView *subview in textView.subviews) {
    subview.backgroundColor = theme.post.backgroundColor;
}

I know this is an old question but I've spent the better part of the day debugging this. I hope other people find it useful.

like image 82
Shawn Throop Avatar answered Sep 21 '22 13:09

Shawn Throop


Well, the UITextView is a more advanced view that's scrollable and supports custom text formatting, so you might not be able to get it to 'not blend'. With other views you should check the opaque checkbox, but I doubt if that will work in this case.

Your best bet would be to use a UILabel instead. You could replace it with a UITextView when the user needs to edit a field, but using UILabel while scrolling should improve the speed considerably.

like image 22
Bob Vork Avatar answered Sep 19 '22 13:09

Bob Vork