Bird
0
0

What will be the result of this Swift code snippet?

medium📝 ui behavior Q13 of 15
iOS Swift - SwiftUI Basics
What will be the result of this Swift code snippet?
let imageView = UIImageView(image: UIImage(systemName: "heart.fill"))
imageView.tintColor = .red
AAn image view showing a red filled heart system icon
BAn image view showing a heart icon with default color (black)
CA runtime error because tintColor cannot be set
DAn empty image view with no image displayed
Step-by-Step Solution
Solution:
  1. Step 1: Load system image "heart.fill"

    UIImage(systemName: "heart.fill") loads a filled heart icon.
  2. Step 2: Set tintColor to red

    Setting imageView.tintColor to .red colors the system icon red.
  3. Final Answer:

    An image view showing a red filled heart system icon -> Option A
  4. Quick Check:

    System icon + tintColor = colored icon [OK]
Quick Trick: System icons respect tintColor for color changes [OK]
Common Mistakes:
  • Assuming system icons ignore tintColor
  • Confusing asset images with system icons for tinting
  • Expecting default black color after setting tintColor

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes