swiftUI styling inconsistencies

Hi Team,

I come from web development background and started learning swiftUI. I found swift UI styling a bit inconsistent between the elements. For example consider the below code, for VStack we're adding styles in the parenthesis. Whereas for the Text element we're adding the styles after the parenthesis. Any idea on why we have these inconsistencies?

        VStack (alignment:.leading,spacing: 5 ){
            Text("Kadari Arun Kumar") .font(.system(size: 32))
}

In HTML/react we have a consistent styling between the elements.

<div id="outer"  style={{textAlign:'center'}}>

<h1> Outer element </h1>

<div id="inner"  style={{textAlign:'left'}}>

<h3> Inner element </h3>

</div>

</div>

Thanks,
Arun

Standard boilerplate answer about SwiftUI

Hi. This forum is for discussions about the Open Source Swift language itself (ongoing development and use of). Your post appears to be more about usage of a framework (probably one usable by Swift). The forum owners think that these kinds of questions are better suited to be asked in other places. Probably the Apple Developer Forums or Stack Overflow. You are more likely to get answers there.

Developer.apple.com/forums

Stackoverflow.com

Good luck!

More specific answer

There's a difference between setting properties of a view and applying a view modifier to a view... See the link below...

2 Likes