0
0
iOS Swiftmobile~20 mins

Image view (system and asset) in iOS Swift - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Image View Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
1:30remaining
Displaying a system image in SwiftUI
What will be displayed by this SwiftUI code snippet?
iOS Swift
import SwiftUI

struct ContentView: View {
  var body: some View {
    Image(systemName: "star.fill")
      .foregroundColor(.yellow)
      .font(.largeTitle)
  }
}
AA large yellow filled star icon
BA large gray filled star icon
CA large yellow outlined star icon
DA large gray outlined star icon
Attempts:
2 left
💡 Hint
The systemName parameter uses SF Symbols, and foregroundColor changes the icon color.
ui_behavior
intermediate
1:30remaining
Displaying an asset image in UIKit
What will this UIKit code display on the screen?
iOS Swift
import UIKit

class ViewController: UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    let imageView = UIImageView(image: UIImage(named: "logo"))
    imageView.frame = CGRect(x: 50, y: 50, width: 100, height: 100)
    view.addSubview(imageView)
  }
}
AA system image named "logo" shown at position (50,50)
BA blank view because "logo" image is not loaded
CAn image named "logo" from the app assets shown at position (50,50) with size 100x100
DAn error because UIImage(named:) cannot be used in viewDidLoad
Attempts:
2 left
💡 Hint
UIImage(named:) loads images from the app's asset catalog by name.
📝 Syntax
advanced
1:30remaining
Correct syntax for system image with rendering mode
Which option correctly creates a SwiftUI Image with system name "heart" and applies original rendering mode?
AImage(systemName: "heart").renderingMode(.original)
BImage(systemName: "heart").renderingMode(.template)
CImage(systemName: "heart", renderingMode: .original)
DImage(systemName: "heart").renderMode(.original)
Attempts:
2 left
💡 Hint
Rendering mode is a modifier method in SwiftUI, not a parameter in initializer.
🔧 Debug
advanced
1:30remaining
Why does UIImage(named:) return nil?
Given this UIKit code, why might imageView.image be nil? let imageView = UIImageView() imageView.image = UIImage(named: "icon")
AUIImageView cannot display images loaded with UIImage(named:)
BThe image named "icon" is missing from the asset catalog or bundle
CUIImage(named:) requires a full file path, not just the name
DimageView.image must be set inside viewDidLoad to work
Attempts:
2 left
💡 Hint
UIImage(named:) returns nil if the image name is not found in assets or bundle.
🧠 Conceptual
expert
2:00remaining
Difference between system and asset images in iOS
Which statement correctly describes the difference between system images and asset images in iOS development?
ASystem images are always raster images, asset images are always vector images
BSystem images must be added manually to assets, asset images are built-in icons from Apple
CSystem images can only be used in UIKit, asset images only in SwiftUI
DSystem images are vector icons provided by Apple (SF Symbols), asset images are custom images added to the app bundle
Attempts:
2 left
💡 Hint
Think about where system images come from and how asset images are added.