A. The animation is missing a fillMode to keep final state.
B. The timingFunction property expects a string, not CAMediaTimingFunction.
C. The keyPath "opacity" is invalid for CABasicAnimation.
D. The timing function name should be .easeInEaseOut, not .easeIn.
Solution
Step 1: Check timingFunction usage
Using CAMediaTimingFunction(name: .easeIn) is correct and supported.
Step 2: Identify missing fillMode
Without setting fillMode and isRemovedOnCompletion, the animation resets after finishing, so the view returns to original opacity.
Final Answer:
The animation is missing a fillMode to keep final state. -> Option A
Quick Check:
Missing fillMode causes animation to revert [OK]
Hint: Add fillMode and isRemovedOnCompletion to keep final state [OK]
Common Mistakes:
Assuming .easeIn is invalid timing function name
Thinking timingFunction needs a string
Ignoring fillMode and completion behavior
5. You want to create a custom animation that moves a view along a path with a non-linear speed, speeding up then slowing down repeatedly. Which approach best achieves this?
hard
A. Use CAKeyframeAnimation with a custom timing function and path to control speed and position.
B. Use CABasicAnimation with a custom CAMediaTimingFunction using control points for the speed curve.
C. Use UIView.animate with linear curve and manually update position in a timer.
D. Use UIView.animate with .curveEaseInOut option repeatedly in a loop.
Solution
Step 1: Understand animation requirements
The animation needs to follow a path and have complex speed changes (speeding up and slowing down repeatedly).
Step 2: Evaluate animation options
CAKeyframeAnimation allows animating along a path and supports custom timing functions for complex speed control, making it ideal here.
Final Answer:
Use CAKeyframeAnimation with a custom timing function and path to control speed and position. -> Option A
Quick Check:
CAKeyframeAnimation + custom timing = best for complex path and speed [OK]
Hint: Use CAKeyframeAnimation for path + custom speed control [OK]
Common Mistakes:
Using UIView.animate for complex path animations
Assuming CABasicAnimation can follow a path
Trying to manually update position with timers
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.