0
0
iOS Swiftmobile~10 mins

withAnimation 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 Boolean state using withAnimation.

iOS Swift
withAnimation {
    self.isVisible = [1]
}
Drag options to blanks, or click blank then click option'
Anil
Bfalse
C0
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-Boolean values like nil or 0 causes errors.
Forgetting to put the state change inside withAnimation block.
2fill in blank
medium

Complete the code to animate the change of a view's opacity using withAnimation.

iOS Swift
withAnimation(.easeIn) {
    self.opacity = [1]
}
Drag options to blanks, or click blank then click option'
A2.0
B0.0
C-1.0
D1.5
Attempts:
3 left
💡 Hint
Common Mistakes
Using values outside 0.0 to 1.0 range causes no visible effect or errors.
Not wrapping the change inside withAnimation block.
3fill in blank
hard

Fix the error in the code by completing the withAnimation call correctly.

iOS Swift
withAnimation([1]) {
    self.offset = CGSize(width: 100, height: 0)
}
Drag options to blanks, or click blank then click option'
A.linear(duration: 0.5)
B0.5
CeaseInOut
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a number or Boolean instead of an Animation object.
Omitting parentheses for the animation function.
4fill in blank
hard

Fill both blanks to animate a scale change with spring animation.

iOS Swift
withAnimation([1]) {
    self.scale = [2]
}
Drag options to blanks, or click blank then click option'
A.spring()
B1.0
C2.0
D.easeIn
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-animation values in the first blank.
Setting scale to 1.0 does not change size.
5fill in blank
hard

Fill all three blanks to animate a color change with easeOut animation and duration 0.3 seconds.

iOS Swift
withAnimation([1]) {
    self.color = [2]
    self.opacity = [3]
}
Drag options to blanks, or click blank then click option'
A.easeOut(duration: 0.3)
B.red
C0.5
D.blue
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong animation types or durations.
Setting color to blue instead of red.
Using opacity values outside 0.0 to 1.0.