Custom animatable property returns NSNull?

旧街凉风 提交于 2019-12-04 05:52:04

So this question has been open for a long-time and I'm concluding that it isn't possible. The code below shows how I would turn on the custom property to be detected within the block. This method is overridden in UIView.

- (id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event {
    NSLog(@"%s - event: %@", __PRETTY_FUNCTION__, event);
    id<CAAction> action = [super actionForLayer:layer forKey:event];
    if ([event isEqualToString:@"circleColor"] && (nil == action || (id)[NSNull null] == action)) {
        return [CABasicAnimation animationWithKeyPath:event];
    }
    return action;
}

The code allows you to animate within the UIView block however there is no way for it to detect that it is within a UIView block. So if you use this code then it will even animate outside of the UIView block which defeats the purpose. I'll monitor for other people's responses, but the only options it seems is to make your own custom UIView animation block system which will allow you to add custom animatable properties. I would imagine that Facebook's Pop framework would be a great alternative solution.

user3892683

Try using [UIView animateWithDuration:0.5 animations:^{ }];

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!