Search code examples
ioscore-animationtoday-extension

Is Core animation not possible in an today extension


I'm building an today extension (widget) in iOS and was hoping it would be possible to add some subtle animations. Specifically i'm trying to transition a text label when the text changes.

My code works as expected in a regular app, but not in the widget. The text changes, but there is no transition.

    CATransition *animation = [CATransition animation];
    animation.duration = 3.0;
    animation.type = kCATransitionFade;
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    [self.heading.layer addAnimation:animation forKey: nil];
    self.heading.text = @"Lorem ipsum dolor sit amet";

This snippet is run inside the viewDidAppear method


Solution

  • CoreAnimation should definitely be available from extensions. Any API that isn't available from within an extension should have its declaration marked with NS_EXTENSION_UNAVAILABLE (visible in the API's header file).