ios - CALayer: Custom animatable properties that update built in animatable properties -
i'm creating custom animatable property on cagradientlayer
derived class has change other built in animatable properties on cagradientlayer
base class , wondering best approach is. i'm updating dependant properties in display method:
@implementation customgradientlayer @dynamic mycustomproperty; + (bool) needsdisplayforkey: (nsstring*)akey { bool needsdisplay = [akey isequaltostring: @"mycustomproperty"]; if (!needsdisplay) { needsdisplay = [super needsdisplayforkey: akey]; } return needsdisplay; } - (void) display { cgfloat mycustomproperty = [self.presentationlayer mycustomproperty]; [catransaction begin]; [catransaction setdisableactions: yes]; // update dependant properties on self [catransaction commit]; [super display]; }
is possible safely update dependant properties in custom property setter instead without affecting underlying calayer
magic?
i found solution interested can use following method without interfering calayar stuff:
- (void) didchangevalueforkey: (nsstring*)akey (void) didchangevalueforkey: (nsstring*)akey { // update dependent properties }
Comments
Post a Comment