0
0
iOS Swiftmobile~10 mins

Transition effects in iOS Swift - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to present a new view controller with a fade transition.

iOS Swift
let newVC = UIViewController()
newVC.modalTransitionStyle = [1]
present(newVC, animated: true)
Drag options to blanks, or click blank then click option'
A.crossDissolve
B.flipHorizontal
C.coverVertical
D.partialCurl
Attempts:
3 left
💡 Hint
Common Mistakes
Using .flipHorizontal causes a flip effect, not a fade.
Forgetting to set modalTransitionStyle results in default animation.
2fill in blank
medium

Complete the code to dismiss the current view controller with a slide down transition.

iOS Swift
modalTransitionStyle = [1]
dismiss(animated: true)
Drag options to blanks, or click blank then click option'
A.coverVertical
B.crossDissolve
C.partialCurl
D.flipHorizontal
Attempts:
3 left
💡 Hint
Common Mistakes
Using .crossDissolve causes a fade, not a slide.
Not setting modalTransitionStyle means default animation is used.
3fill in blank
hard

Fix the error in the code to set a custom transition delegate.

iOS Swift
let newVC = UIViewController()
newVC.transitioningDelegate = [1]
present(newVC, animated: true)
Drag options to blanks, or click blank then click option'
AUIViewController()
Bnil
Cdelegate
Dself
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning nil disables custom transitions.
Assigning a new UIViewController instance does not work as delegate.
4fill in blank
hard

Fill both blanks to create a transition animation with a flip effect.

iOS Swift
let transition = CATransition()
transition.type = [1]
transition.subtype = [2]
view.window?.layer.add(transition, forKey: nil)
Drag options to blanks, or click blank then click option'
Aflip
BfromLeft
CfromRight
Dfade
Attempts:
3 left
💡 Hint
Common Mistakes
Using "fade" type does not create a flip effect.
Mixing up subtype directions causes unexpected animation.
5fill in blank
hard

Fill all three blanks to create a dictionary for a transition with fade type and duration 0.5.

iOS Swift
let options = [
  kCATransitionType: [1],
  kCATransitionSubtype: [2],
  kCATransitionDuration: [3]
]
Drag options to blanks, or click blank then click option'
A"fade"
B"fromRight"
C0.5
D"push"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "push" instead of "fade" changes the animation style.
Setting duration as a string instead of a number causes errors.