0
0
iOS Swiftmobile~10 mins

Why animations polish user experience in iOS Swift - Test Your Understanding

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

Complete the code to animate a view's opacity change smoothly.

iOS Swift
UIView.animate(withDuration: 1.0) {
  myView.alpha = [1]
}
Drag options to blanks, or click blank then click option'
A-1
B1.5
C0.5
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using values greater than 1 or negative values causes no visible animation or errors.
2fill in blank
medium

Complete the code to animate a view's position change using a spring effect.

iOS Swift
UIView.animate(withDuration: 1.0, delay: 0, usingSpringWithDamping: [1], initialSpringVelocity: 0, options: [], animations: {
  myView.center.x += 100
}, completion: nil)
Drag options to blanks, or click blank then click option'
A2.0
B-0.5
C1.5
D0.5
Attempts:
3 left
💡 Hint
Common Mistakes
Using values greater than 1 or negative values disables spring effect.
3fill in blank
hard

Fix the error in the animation block to correctly animate background color change.

iOS Swift
UIView.animate(withDuration: 0.5) {
  myView.backgroundColor = [1]
}
Drag options to blanks, or click blank then click option'
AUIColor.red
BUIColor.redColor()
CredColor()
Dcolor.red
Attempts:
3 left
💡 Hint
Common Mistakes
Using Objective-C style methods like redColor() causes errors.
4fill in blank
hard

Fill both blanks to animate a view's scale transform to double size and back.

iOS Swift
UIView.animate(withDuration: 0.3, animations: {
  myView.transform = CGAffineTransform.[1](x: 2.0, y: 2.0)
}) { _ in
  UIView.animate(withDuration: 0.3) {
    myView.transform = CGAffineTransform.[2]()
  }
}
Drag options to blanks, or click blank then click option'
Ascale
Btranslate
Cidentity
Drotate
Attempts:
3 left
💡 Hint
Common Mistakes
Using translate or rotate instead of scale causes wrong animation.
5fill in blank
hard

Fill all three blanks to animate a view's position, opacity, and background color change together.

iOS Swift
UIView.animate(withDuration: 1.0) {
  myView.center.x += [1]
  myView.alpha = [2]
  myView.backgroundColor = UIColor.[3]
}
Drag options to blanks, or click blank then click option'
A50
B0.3
Cblue
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using alpha values outside 0-1 or invalid color names causes errors.