Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounded corners in swiftui list sections

Tags:

Here is a screen shot of iOS 13 Health app - User profile. I recently started with swiftui and wondering how to develop a screen like below. I tried list styles plain and grouped. But I couldn't get the look of below layout.

Can UI like this develop purely using swiftui-list?

I am specially looking for rounded sections and including a image inside the list. iOS 13 Health Application - User profile

like image 275
uiroshan Avatar asked Sep 15 '19 16:09

uiroshan


People also ask

How do you round the corners of a view SwiftUI?

You can round the corners of any SwiftUI view by using the cornerRadius() modifier. Simply add a value to the cornerRadius to control how rounded you want the view to be.

How do I set the corner radius in SwiftUI?

Any SwiftUI view can have its corners rounded using the cornerRadius() modifier. This takes a simple value in points that controls how pronounced the rounding should be.


1 Answers

As of iOS 14, you can use the code below. It works just perfectly, just like in UIKit.

List {     Section {         Text("Item 1")         Text("Item 2")         Text("Item 3")     }          Section {         Text("Item 4")         Text("Item 5")         Text("Item 6")     } }.listStyle(InsetGroupedListStyle()) // this has been renamed in iOS 14.*, as mentioned by @Elijah Yap .environment(\.horizontalSizeClass, .regular) 

Thank you.

like image 168
NG235 Avatar answered Oct 27 '22 07:10

NG235