Practice 50 Swift Animations Programming Questions, TechnoVlogs

Practice 50 Swift Animations Programming Questions


Q1. Write a Swift program to animate a UIView from left to right across the screen.
  Input: A UIView with initial position off-screen on the left.
  Output: The UIView animates to the right side of the screen.

Q2. Write a Swift program to animate a UIView to change its background color to red.
  Input: A UIView with a background color.
  Output: The UIView background color changes to red over 1 second.

Q3. Write a Swift program to animate a UILabel with a fade-in effect.
  Input: A UILabel with initial opacity set to 0.
  Output: The UILabel fades in to full opacity over 2 seconds.

Q4. Write a Swift program to animate a UIButton to scale up and down.
  Input: A UIButton with initial scale set to 1.
  Output: The UIButton scales up and down repeatedly.

Q5. Write a Swift program to animate a UIView to rotate 90 degrees.
  Input: A UIView with an initial rotation angle of 0 degrees.
  Output: The UIView rotates 90 degrees over 1 second.

Q6. Write a Swift program to animate a UILabel to move vertically from top to bottom.
  Input: A UILabel positioned at the top of the screen.
  Output: The UILabel animates down to the bottom of the screen.

Q7. Write a Swift program to animate a UIImageView to change its image with a fade effect.
  Input: A UIImageView with an initial image.
  Output: The image fades to the new image over 1 second.

Q8. Write a Swift program to animate a UIView to bounce up and down.
  Input: A UIView with initial position in the center of the screen.
  Output: The UIView bounces up and down repeatedly.

Q9. Write a Swift program to animate a UILabel text size change.
  Input: A UILabel with initial font size 20.
  Output: The font size of the text increases to 40.

Q10. Write a Swift program to animate a UIButton to change its background color when pressed.
   Input: A UIButton with initial background color.
   Output: The background color of the button changes to blue when pressed.

Q11. Write a Swift program to animate a UIView to change its opacity.
   Input: A UIView with an initial opacity of 1.
   Output: The UIView fades to 0 opacity over 2 seconds.

Q12. Write a Swift program to animate a UIView to rotate continuously in a loop.
   Input: A UIView with initial rotation set to 0 degrees.
   Output: The UIView rotates 360 degrees continuously.

Q13. Write a Swift program to animate a UILabel to move horizontally with a spring effect.
   Input: A UILabel with initial position on the left side of the screen.
   Output: The UILabel moves to the right side with a spring effect.

Q14. Write a Swift program to animate a UIButton to rotate 180 degrees when clicked.
   Input: A UIButton with initial rotation of 0 degrees.
   Output: The UIButton rotates 180 degrees on click.

Q15. Write a Swift program to animate a UIView to shrink to 50% of its size and then grow back.
   Input: A UIView with initial size of 100x100.
   Output: The UIView shrinks to 50x50 and then grows back to 100x100.

Q16. Write a Swift program to animate a UILabel text color change from red to green.
   Input: A UILabel with initial text color red.
   Output: The text color changes to green over 2 seconds.

Q17. Write a Swift program to animate a UIImageView to zoom in on an image.
   Input: A UIImageView with initial scale set to 1.
   Output: The image zooms in by scaling the UIImageView.

Q18. Write a Swift program to animate a UIView to rotate and change its color at the same time.
   Input: A UIView with initial rotation of 0 degrees and color red.
   Output: The UIView rotates 90 degrees and changes color to blue.

Q19. Write a Swift program to animate a UIButton to change text color on hover.
   Input: A UIButton with initial text color red.
   Output: The text color changes to blue when hovered over.

Q20. Write a Swift program to animate a UILabel from top to bottom with opacity change.
   Input: A UILabel initially positioned at the top with opacity set to 0.
   Output: The UILabel moves to the bottom and fades in.

Q21. Write a Swift program to animate a UIView to move from one point to another.
   Input: A UIView initially positioned at point (0,0).
   Output: The UIView moves to point (100, 100).

Q22. Write a Swift program to animate a UIView to rotate on its own axis.
   Input: A UIView with initial rotation of 0 degrees.
   Output: The UIView rotates 360 degrees around its own axis.

Q23. Write a Swift program to animate a UIButton to scale up on click.
   Input: A UIButton with initial scale set to 1.
   Output: The UIButton scales up by 1.5 times when clicked.

Q24. Write a Swift program to animate a UILabel to change its text.
   Input: A UILabel with initial text "Hello".
   Output: The UILabel changes its text to "World" with a fade effect.

Q25. Write a Swift program to animate a UIView to change background color with a fade effect.
   Input: A UIView with initial background color red.
   Output: The background color fades to green.

Q26. Write a Swift program to animate a UIView to change its frame size.
   Input: A UIView with initial frame size 100x100.
   Output: The UIView resizes to 150x150.

Q27. Write a Swift program to animate a UIImageView to rotate and scale at the same time.
   Input: A UIImageView with initial rotation of 0 degrees and scale of 1.
   Output: The UIImageView rotates and scales simultaneously.

Q28. Write a Swift program to animate a UIView to move in a circular path.
   Input: A UIView initially positioned at the center.
   Output: The UIView moves in a circular path around the center.

Q29. Write a Swift program to animate a UIButton to change its border color and width.
   Input: A UIButton with initial border color red and width 2.
   Output: The border color changes to green and width to 4 over 1 second.

Q30. Write a Swift program to animate a UILabel with a bounce effect when it appears.
   Input: A UILabel initially hidden.
   Output: The UILabel appears with a bounce effect.

Q31. Write a Swift program to animate a UIView to scale and change opacity simultaneously.
   Input: A UIView with initial scale 1 and opacity 1.
   Output: The UIView scales up and fades out.

Q32. Write a Swift program to animate a UIImageView to rotate continuously and change its image.
   Input: A UIImageView with initial image.
   Output: The UIImageView rotates continuously and changes its image.

Q33. Write a Swift program to animate a UIButton to rotate and change background color on click.
   Input: A UIButton with initial rotation of 0 degrees and background color blue.
   Output: The UIButton rotates and changes to red background color on click.

Q34. Write a Swift program to animate a UIView to change its position with a spring animation.
   Input: A UIView with initial position at (0, 0).
   Output: The UIView moves to position (100, 100) with a spring effect.

Q35. Write a Swift program to animate a UIView to shrink and change color on hover.
   Input: A UIView with initial size 100x100 and color green.
   Output: The UIView shrinks to 80x80 and changes color to blue.

Q36. Write a Swift program to animate a UILabel to move from one point to another with fading.
   Input: A UILabel with initial position at (0, 0).
   Output: The UILabel moves to (200, 200) and fades in.

Q37. Write a Swift program to animate a UIButton to rotate on click.
   Input: A UIButton with initial rotation of 0 degrees.
   Output: The UIButton rotates 180 degrees on click.

Q38. Write a Swift program to animate a UIView to fade in and out in a loop.
   Input: A UIView with initial opacity of 0.
   Output: The UIView fades in and out repeatedly.

Q39. Write a Swift program to animate a UILabel to bounce vertically.
   Input: A UILabel with initial position.
   Output: The UILabel bounces vertically up and down.

Q40. Write a Swift program to animate a UIImageView to move diagonally.
   Input: A UIImageView with initial position at (0, 0).
   Output: The UIImageView moves diagonally to (200, 200).

Q41. Write a Swift program to animate a UIView with a fade-in and scale-up effect.
   Input: A UIView with initial opacity 0 and scale 1.
   Output: The UIView fades in and scales up simultaneously.

Q42. Write a Swift program to animate a UIButton to move from left to right on hover.
   Input: A UIButton initially at the left.
   Output: The UIButton moves to the right when hovered over.

Q43. Write a Swift program to animate a UIView to rotate and change text color at the same time.
   Input: A UIView with initial rotation of 0 degrees and text color red.
   Output: The UIView rotates 90 degrees and text color changes to blue.

Q44. Write a Swift program to animate a UILabel to scale up when tapped.
   Input: A UILabel with initial scale 1.
   Output: The UILabel scales up by 1.5 times when tapped.

Q45. Write a Swift program to animate a UIImageView to rotate in a continuous loop.
   Input: A UIImageView with initial rotation of 0 degrees.
   Output: The UIImageView rotates 360 degrees continuously.

Q46. Write a Swift program to animate a UIView to change its corner radius.
   Input: A UIView with initial corner radius of 0.
   Output: The corner radius changes to 20.

Q47. Write a Swift program to animate a UILabel with a pulsing effect.
   Input: A UILabel with initial opacity set to 1.
   Output: The UILabel pulses by changing its opacity.

Q48. Write a Swift program to animate a UIButton to change its text size on press.
   Input: A UIButton with initial text size 14.
   Output: The text size changes to 18 when the button is pressed.

Q49. Write a Swift program to animate a UIView to move in a zigzag pattern.
   Input: A UIView initially positioned at (0, 0).
   Output: The UIView moves in a zigzag path.

Q50. Write a Swift program to animate a UILabel to shake horizontally.
   Input: A UILabel with initial position at (100, 100).
   Output: The UILabel shakes horizontally. 

Social Share

Bikki Singh Instructor TechnoVlogs

Bikki Singh

Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!