I created a "TransformView
" subclassing UIView
in order to support a double-sided view which I am using in a flip animation. This has been suggested in other posts, eg:
How to rotate a flat object around its center in perspective view?
@interface TransformView : UIView
@end
@implementation TransformView
+ (Class)layerClass {
return [CATransformLayer class];
}
@end
It all works fine, but I get a warning every time I create a TransformView object using:
TransformView *newTransformView=[[TransformView alloc] initWithFrame:frame];
The warning says:
- changing property opaque in transform-only layer, will have no effect
I guess the UIView
class is initialising the opaque property which is usually fine for a CALayer
but not a CATransformLayer
.
Is the subclassing code quite dodgy? If so, how else can you create a 2-sided view for flip animations?
Any ideas for how to stop the warning?
I have a suspicion that creating a TransformView
from a nib file rather than initWithFrame
avoids the warning, but is seem cludgy to have to do this just to avoid the warning.
Your can avoid the warning by adding this extension somewhere in your code:
@implementation CATransformLayer (MyExtension)
-(void)setOpaque:(BOOL)opaque
{
return;
}
@end
Of course this will also stop the warning for your own mistaken attempts to set the opaque property of a CATransformLayer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With