I have a UIView subclass in my iOS app and the content for that UIView is 3 
CALayers, each with a bitmap image for their content, added as sublayers of the 
UIView's layer. Each of the CALayers is the full size of the UIView's layer 
(they have transparency to composite them together). 

When the UIView is resized the setFrame: method is called and I have a custom 
implementation of that which sets the bounds of the sublayers so they again 
fill the UIView's layer, and draws a new bitmap for each of them of the right 
size and sets it into their contents. 

However, when I resize, there's a brief flash of the current content, before 
it's been redrawn, stretched to fill the new sized window, before the new 
content replaces it. Nothing I've tried has been able to stop that brief flash 
and I can't figure out where it's coming from. 

I've checked that, at the start of the setFrame: method the UIView's layer 
hasn't already been resized, it hasn't. So before setting the frame bounds and 
center I've tried removing the content from the sublayers, that didn't work, 
still flash, I've tried removing the layers totally before sizing the UIView 
and putting them back at the end after sizing and giving them new content, that 
didn't work, so this resized drawing doesn't appear to be coming from the 
UIView's layer. 

So I looked at the individual 3 layers which have content on them. I can see 
how, if the bounds change and the content doesn't, the layer will stretch the 
bitmap to the window,  so I've ensure that I call setContent:nil *before* I 
resize the layer. Of course content is an animatable property as is bounds so 
it was quite possible the layer is animating the change in bounds and content 
and starts with a stretched 'old' content, so I turned off animations both by 
using layer's setActions: method with NSNull for each of the actions contents, 
orderIn, orderOut, bounds, hidden and sublayers AND I also put the whole thing 
in a CATransaction into which I've done this to disable actions. 

        [ CATransaction  setValue:(id)kCFBooleanTrue 
forKey:kCATransactionDisableActions ];

and just for good measure I've done one transaction to remove the contents, 
committed it, then a second transaction to resize the layer and add new 
content. None of these things have worked, I still see stretched (or 
compressed) content for a fraction of a second before the content I want is 
redrawn. I've also turned off autoresizing of subviews all down the line and 
set the mode to 'redraw', just incase the layers were being resized early, 
still no good and lastly I've moved the code from setFrame: to layoutSubviews 
and that makes no difference

I'm out of ideas. Perhaps there is something I just fail to understand in the 
way the model and presentation layers work because certainly in the model no 
CALayer is resized whilst it still has content set in it, I've printed the 
bounds of the layer out before I resize it, so I cannot see why the old, now 
gone, content briefly shows up stretched. 
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to