I'm trying to create an animation in a custom class that will be triggered in an animation block like all UIView elements.
my class:
@interface SmileyFace : NSObject
@property (strong, nonatomic) uicolor* color;
@end
I'm changing color with:
[UIView animateWithDuration:3 animations:^{
myView.frame = newFrame;
smileyView.color = [uicolor redcolor];
}];
Now, In the setter of the property color, I need to find out if it should be animated, and add a custom animation:
-(void)setColor:(UIColor *)color
{
_color = color;
NSLog(@"new frame");
if ([CATransaction animationDuration] > 0)
[self changeColor:color withAnimationWithDuration:[CATransaction animationDuration]];
else
[self changeColor:color];
}
Since my object is a custom object, I'm not sure how to access the duration of the animation. From CAtransaction, I'm always getting 0.25 as duration.
Any help will be appreciated!