Latest Post

How to adjust SwiftUI text alignment what are tuple in python iOS interview Question

swiftui text alignment provides a lot of useful controls for aligning views, and I’d want to walk you through each one so you can understand how they work.

We can se the Frame to adjust the width and Height of the Text which we want to change the frame parameter of the Text . We can also allign the Frame width and Height of it

Text("Hello SwiftUI")
    .frame(width: 300, height: 300)

We can also use the geometryReader for accessing the device size and frame height and width also we can use the proportionality by using it.

Text("Hello SwiftUI")
    .frame(width: geometry.size.widht, height: geometry.size.height)

To change the SwiftUI Text alignment we can use the alignment() parameter inside the frame .The alignment parameter adjust the text alignment based on the use cases of the user.

Text("Hello SwiftUI")
    .frame(width: geometry.size.widht , height: geometry.size.height , alignment: .topLeading)

Alignment of SwiftUI are varied based on the following categories

  • TopLeading
  • Leading
  • bottomleading
  • Top
  • Center
  • Bottom
  • TopTrailing
  • Trailing
  • BottomTrailing

Leave a Reply

Your email address will not be published.