Bird
0
0

Which of the following is the correct way to add 20 points of padding around a Text view in SwiftUI?

easy📝 Syntax Q12 of 15
iOS Swift - SwiftUI Basics
Which of the following is the correct way to add 20 points of padding around a Text view in SwiftUI?
AText("Hello").padding(20)
BText("Hello").padding(EdgeInsets(top: 20, leading: 20, bottom: 20, trailing: 20))
CAll of the above
DText("Hello").padding(.all, 20)
Step-by-Step Solution
Solution:
  1. Step 1: Review padding syntax

    SwiftUI allows padding with a simple number, with edges and length, or with EdgeInsets struct.
  2. Step 2: Check each option

    Text("Hello").padding(20) uses padding(20) which adds 20 points all around.
    Text("Hello").padding(.all, 20) uses padding(.all, 20) which also adds 20 points all around.
    Text("Hello").padding(EdgeInsets(top: 20, leading: 20, bottom: 20, trailing: 20)) uses EdgeInsets with 20 points on all sides.
    All are valid ways.
  3. Final Answer:

    All of the above -> Option C
  4. Quick Check:

    Multiple padding syntaxes work [OK]
Quick Trick: All padding methods shown add 20 points correctly [OK]
Common Mistakes:
  • Using padding without parameters incorrectly
  • Confusing padding edges syntax
  • Missing EdgeInsets struct format

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes