I have a UITableViewCell
subclass with backgroundView
set to my own UIView
object. This UIView
object contains three CALayer
layers. I implemented - (void)layoutSubviews
where I update all my CALayer
layers. The problem is autorotation.
When I rotate from landscape to portrait mode there's this cosmetic issue:
During the animation, all my CALayer
layers are as narrow as in portrait mode.
It seems that this guy is right:
When
layoutSubviews
gets called during an orientation change, the view's bounds are already set to what they will be at the conclusion of the rotation.
So, where should I update my layers to achieve proper autorotation? The view is already rotating them, so I suppose there's no need to do any custom animations, just adjust the size. Right?
Figured it out:
CALayer
+ add sublayers into itCALayer
's - (void)layoutSublayers
methodsubclass UIView
+ override + (Class)layerClass
in it:
+ (Class)layerClass {
return [SubclassedCALayer class];
}
set the subclassed UIView
as backgroundView
of UITableViewCell