0

I'm trying to figure out why the navigation title is not working with some devices, but I'm not able to figure out this issue. Can any one please help me to find out this issue, why the navigation title shows only the first 3 letters and after showing?

I have attached the Screenshot also please check.

iPhone 11 Device

Screenshot

iPhone 11 Simulator

Screenshot

Code:-

var body: some View {
    ZStack {
        Color.init(ColorConstantsName.MainThemeBgColour)
            .ignoresSafeArea()
        GeometryReader { geo in
            ScrollView(.vertical) {
                Text("Testing")
            }
        }
    }
    .navigationBarBackButtonHidden(true)
    .navigationTitle(CommonAllString.BlankStr)
    .navigationViewStyle(.stack)
    .navigationBarTitleDisplayMode(.inline)
    .navigationBarItems(leading:AnyView(leadingButton),trailing:AnyView(self.trailingButton))
    .foregroundColor(Color.white)
}

var trailingButton: some View {
    HStack {
        Image(systemName: ImageConstantsNameForChatScreen.PersonImg)
            .padding(.trailing)
        Image(ImageConstantsName.DTRShareIconImg)
            .resizable().frame(width: 20, height: 20)
    }
}
Sham Dhiman
  • 1,348
  • 1
  • 21
  • 59
  • Welcome to Stack Overflow! Please take the [tour](https://stackoverflow.com/tour) and see: [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). – Yrb Nov 12 '21 at 16:40
  • Can't reproduce with what you have but the `navigationBarItems` and `navigationBarTitleDisplayMode` are deprecated you should change to `.toolbar` in iOS 14 and 15 you might get better results. – lorem ipsum Nov 12 '21 at 18:33

1 Answers1

0

Below Code Working:-

struct PSScreen: View {

var body: some View {
    ZStack {
        Color.init("Colour")
            .ignoresSafeArea()
        VStack{
            Text("PSScreen")
        }
    }
    .navigationBarBackButtonHidden(true)
    .navigationBarTitle("", displayMode: .inline)
    .navigationViewStyle(.stack)
    .navigationBarTitleDisplayMode(.inline)
    .toolbar {
        ToolbarItem(placement: .navigationBarLeading) {
            leadingButton.frame(width: 50, alignment: .leading)
        }
        
        ToolbarItem(placement: .navigationBarTrailing) {
            trailingButton
        }
    }.foregroundColor(Color.white)
}

var leadingButton: some View {
    HStack{
        Text("Profile")
    }
}

var trailingButton: some View {
    HStack {
        Image(systemName: "Person")
            .padding(.trailing)
        Image("Share")
            .resizable().frame(width: 20, height: 20)
       }
    }
}
Sham Dhiman
  • 1,348
  • 1
  • 21
  • 59