SwiftUI different behavior on different iOS versions

314 Views Asked by At

I have been developing an app with minimum iOS 13, but whole development process was done on iOS 15. Now when testing the iOS 13 devices, I noticed some problems.

Minimalistic example: You have a list of items, where each item contains leading icon, with a title and a subtitle vertically stacked. To adapt to various screen sizes, I attached a .minimumScaleFactor() to the texts so they would scale down when needed. That's working nicely on iOS 15. After a whole lot of testing, it also works on iOS 13.4 that is the oldest where I've got it working, so, iOS 13 - <13.4 is in question here.

On the screenshot you can see iPhone 8 13.3 vs iPhone 8 13.4, the text is scaled down even when there is space available. On iPhone 6s Plus 13.3 there is even more available space (screen size).

iOS comparison

And the code:

struct Viewwww: View {
    var title = "This is a title This is a title This is a title This is a title This is a title "
    var subtitle = "This is a subtitle This is a subtitle This is a subtitle This is a subtitle This is a subtitle "
    var body: some View {
        VStack{
            Text("Onboarding test").font(.title).multilineTextAlignment(.center).lineLimit(2)
            Spacer()
            buildItem()
            buildItem()
            buildItem()
            buildItem()
            buildItem()
            Spacer()
        }.padding(.horizontal, 20)
            .padding(.top, 30)
    }
    @ViewBuilder
    func buildItem() -> some View {
        
        HStack(alignment: .top, spacing: 20){
            VStack {
                Image(systemName: "pin").resizable().scaledToFit().frame(width: 44, height: 44)
            }
            VStack(alignment: .leading, spacing: 10){
                Text(title).font(Font.title).minimumScaleFactor(0.5)
                Text(subtitle).font(Font.body).minimumScaleFactor(0.5)
                
            }
            Spacer()
            
        }.frame(maxWidth: .infinity).background(Color.red)
    }
}

So anyone has experienced this, and can help? Thank you!

0

There are 0 best solutions below