簡體   English   中英

SwiftUI 中的文本視圖不僅顯示更大的字體

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

在 DoctorHomePage 中,我有一個分組列表,在列表上方我想添加一個文本視圖,但文本視圖僅在我將字體更改為更大的字體時才顯示,但它太大了,我希望它更小。 這是我的代碼:

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)
    }
}

以下是一些屏幕截圖,可幫助您了解問題: 在此處輸入圖片說明

第一張圖片沒有文本視圖。

第二張圖片的字體大小為 60。

第三張圖片的字體大小為 30。

似乎有些奇怪/錯誤的行為。

設置歡迎文本的 zIndex 將解決您的問題。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM