svenyonson
svenyonson

Reputation: 1909

iOS 15.3 has broken SwiftUI layout

I just upgraded my phone from 15.x (I think 15.2) to 15.3, and my SwiftUI layout is broken, seems to be a List border issue.

Here is the code, followed by a screen shot of normal behavior (13.x to 15.x) and then what I see in 15.3

struct SessionView: View {
    var title: String
    var panel: Int
    var index: Int
    var range: [Int] = [0,2,3,4]
    
    @EnvironmentObject var state: MainViewModel
    @EnvironmentObject var content: ContentViewModel

    @ViewBuilder
    var body: some View {
        VStack() {
            // -- Header
            HStack() {
                Text(" ")
                Image(self.state.panelIcon(panel: panel)).resizable().frame(width: 12.0, height: 12.0)
                Text(title)
                Spacer()
            }.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
            .background(Color(red: 0.9, green: 0.9, blue: 0.9))
            .onTapGesture {
                showDetailDialog()
            }

            // -- Rows
            List {
                ForEach(0..<5) { i in
                    if i != 1 { // Skip IP address
                        HStack(alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/, spacing: -4, content: {
                            Text("\(state.keyValues[i+index]!.key)").frame(minWidth: 120, maxHeight: 20, alignment: .leading)
                                .font(Font.system(size: 15, design: .default)).padding(0)
                            Text("\(state.keyValues[i+index]!.value)").frame(maxHeight: 20, alignment: .leading)
                                .font(Font.system(size: 15, design: .default)).padding(0)
                        }).frame(height: 10)
                    }
                }
            }.environment(\.defaultMinListRowHeight, 10)
            .frame(height: 4*20+20)
            .listStyle(DefaultListStyle()).environment(\.defaultMinListRowHeight, 8).onAppear {
                UITableView.appearance().isScrollEnabled = false
            }.layoutPriority(1)
        }.overlay(
            RoundedRectangle(cornerRadius: 10)
                .stroke(Color(red: 0.8, green: 0.8, blue: 0.8), lineWidth: 1.25)
        ).background(Color.white)
        
    }
    .
    .
    .
}

enter image description here

enter image description here

Upvotes: 0

Views: 460

Answers (1)

BPS
BPS

Reputation: 365

I had this problem too. However, it is not a border issue. When you updated your iPhone, the default list style for SwiftUI changed. The old default style is now called PlainListStyle(). Use that instead to get the old look back.

List {
    
}.listStyle(PlainListStyle())

Upvotes: 2

Related Questions