0
0
iOS Swiftmobile~10 mins

Animated state changes 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 animate the change of a view's background color.

iOS Swift
UIView.animate(withDuration: 1.0) {
    self.view.backgroundColor = [1]
}
Drag options to blanks, or click blank then click option'
AUIColor.red
Bview.backgroundColor
CUIColor.clear
Dself.backgroundColor
Attempts:
3 left
💡 Hint
Common Mistakes
Using view.backgroundColor without self
Trying to assign a non-UIColor value
Changing backgroundColor outside the animation block
2fill in blank
medium

Complete the code to animate the change of a view's alpha property.

iOS Swift
UIView.animate(withDuration: 0.5) {
    self.myView.[1] = 0.0
}
Drag options to blanks, or click blank then click option'
Aframe
Bcenter
Calpha
DbackgroundColor
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to animate frame or center instead of alpha
Using incorrect property names
Not placing the change inside the animation block
3fill in blank
hard

Fix the error in the animation code by completing the missing method call.

iOS Swift
UIView.[1](withDuration: 0.3) {
    self.button.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)
}
Drag options to blanks, or click blank then click option'
AanimateWithDuration
Banimate
CanimateDuration
DanimateChange
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like animateWithDuration
Missing the 'withDuration' label
Trying to call non-existent animation methods
4fill in blank
hard

Fill both blanks to animate a view's frame change with a spring effect.

iOS Swift
UIView.[1](withDuration: 0.5, delay: 0, usingSpringWithDamping: [2], initialSpringVelocity: 0, options: [], animations: {
    self.box.frame = CGRect(x: 50, y: 50, width: 100, height: 100)
}, completion: nil)
Drag options to blanks, or click blank then click option'
Aanimate
BanimateWithDuration
C0.5
D1.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method names
Setting damping outside 0 to 1 range
Omitting required parameters
5fill in blank
hard

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

iOS Swift
UIView.[1](withDuration: 1.0, animations: {
    self.cardView.backgroundColor = [2]
    self.cardView.[3] = 0.5
})
Drag options to blanks, or click blank then click option'
Aanimate
BUIColor.blue
Calpha
DanimateWithDuration
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names
Trying to animate properties outside the animations block
Using wrong property names