Text view in SwiftUI doesn't show only with bigger font

Viewed 73

In DoctorHomePage I have a grouped list and above the list I want to add a text view, but the text view doesn't show only if I change the font to a bigger one, but it is too big and I want it smaller. Here is my code:

import SwiftUI
import Combine

struct DoctorHomePage: View {

    @Binding var shouldPopToRootView : Bool

    @State private var curent: Int? = nil
    @State private var isActive: Bool = false
    @State private var id = 0
    let defaults = UserDefaults.standard
    let networkRequest = Network()
    @State var cancelable: AnyCancellable? = nil
    @State var localPatients : [Patients] = []

    var body: some View {
        NavigationView {
            VStack {
                NavigationLink(destination: ContentView(), tag: 1, selection: $curent) {
                    EmptyView()
                }
                Text("Welcome, doctor!") // this is the text that I want to add
                .font(.system(size: 30)).fontWeight(.ultraLight)
                .padding(.top, 50)
                // PATIENT LIST
                List(localPatients) { patient in
                    VStack(alignment: .leading) {
                        Text(patient.name)
                    }
                }.listStyle(GroupedListStyle())
                    .onAppear(perform: {
                    self.loadPatients()
                    connCode = self.defaults.integer(forKey: "doctorID")
                    self.id = connCode
                })

            }.edgesIgnoringSafeArea([.top, .bottom])
        }.navigationBarBackButtonHidden(true)
        .navigationBarHidden(true)
    }
}

Here are some screen shots to help you understand the problem: enter image description here

The first image is with no text view.

The second image is with the font size of 60.

The third image is with the font size of 30.

1 Answers

Seems like some strange / buggy behavior.

Setting the zIndex of you welcome text will fix your problem.

Text("Welcome, doctor!").zIndex(1)
Related