Bird
0
0

Which of the following is the correct syntax to apply a font size of 18 to a Text view in SwiftUI?

easy📝 Syntax Q3 of 15
iOS Swift - SwiftUI Basics
Which of the following is the correct syntax to apply a font size of 18 to a Text view in SwiftUI?
AText("Hello").fontSize = 18
BText("Hello").fontSize(18)
CText("Hello").font(.system(size: 18))
DText("Hello").setFontSize(18)
Step-by-Step Solution
Solution:
  1. Step 1: Recall the correct font size syntax

    In SwiftUI, font size is set using .font(.system(size: value)).
  2. Step 2: Identify incorrect syntax

    .fontSize() and .setFontSize() do not exist, and .fontSize = 18 is invalid.
  3. Final Answer:

    Text("Hello").font(.system(size: 18)) -> Option C
  4. Quick Check:

    Use .font(.system(size:)) for font size = A [OK]
Quick Trick: Use .font(.system(size:)) to set font size [OK]
Common Mistakes:
  • Using non-existent .fontSize() modifier
  • Trying to assign fontSize as a property
  • Confusing method names for font size

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes