Challenge - 5 Problems
Master of Custom Animation Timing
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the visible effect of this animation code?
Consider this Swift code snippet for a UIView animation with a custom timing curve. What will the user see when this animation runs?
iOS Swift
UIView.animate(withDuration: 2.0, delay: 0, options: [.curveEaseInOut], animations: { view.alpha = 0 }, completion: nil)
Attempts:
2 left
💡 Hint
Think about what the .curveEaseInOut option means for animation speed over time.
✗ Incorrect
The .curveEaseInOut option makes the animation start slowly, speed up in the middle, and slow down again at the end, creating a smooth fade out effect.
📝 Syntax
intermediate2:00remaining
Which option correctly creates a custom timing curve animation?
You want to animate a view's position with a custom cubic timing curve. Which code snippet correctly uses UIViewPropertyAnimator with a custom timing curve?
Attempts:
2 left
💡 Hint
Look for the option that uses UICubicTimingParameters with control points.
✗ Incorrect
Option A correctly creates a UICubicTimingParameters object with custom control points and uses it to initialize UIViewPropertyAnimator, then adds animations and starts it.
❓ lifecycle
advanced2:00remaining
What happens if you call startAnimation() twice on the same UIViewPropertyAnimator?
Given a UIViewPropertyAnimator instance, what is the effect of calling startAnimation() two times in a row without stopping or pausing?
iOS Swift
let animator = UIViewPropertyAnimator(duration: 1.0, curve: .easeInOut) { view.alpha = 0 } animator.startAnimation() animator.startAnimation()
Attempts:
2 left
💡 Hint
Think about how UIViewPropertyAnimator manages its running state.
✗ Incorrect
Calling startAnimation() on an already running animator does nothing; the animation continues without restarting or crashing.
advanced
2:00remaining
How to synchronize a custom animation with a navigation controller transition?
You want to add a custom timing animation to a view during a UINavigationController push transition. Which approach correctly synchronizes your animation with the navigation transition?
Attempts:
2 left
💡 Hint
Custom navigation animations require coordination with the transition system.
✗ Incorrect
Implementing UIViewControllerAnimatedTransitioning and using the transitionContext allows your animation to run in sync with the navigation controller's transition.
🔧 Debug
expert2:00remaining
Why does this custom timing animation freeze halfway?
This code uses UIViewPropertyAnimator with a custom timing curve, but the animation freezes halfway and never completes. What is the most likely cause?
iOS Swift
let timing = UICubicTimingParameters(controlPoint1: CGPoint(x: 1.5, y: -0.5), controlPoint2: CGPoint(x: 0.5, y: 1.5)) let animator = UIViewPropertyAnimator(duration: 2.0, timingParameters: timing) animator.addAnimations { view.alpha = 0 } animator.startAnimation()
Attempts:
2 left
💡 Hint
Check the valid range for cubic Bezier control points in timing curves.
✗ Incorrect
Control points for UICubicTimingParameters must be within [0,1] range for x and y. Points outside this range can cause the animation to freeze or behave incorrectly.