Post

Replies

Boosts

Views

Activity

navigationBarItems does not work as soon as position changed
Dear experts. As part of NavigationView there were added navigationBarItems. The button defined in the following way.  }.font(Font.custom("Muli",size:18)).background(Image("Header"), alignment: .center).navigationBarTitle("News",displayMode: .large)                .navigationBarItems(trailing:                     Button(action: {                         if self.newArticles{                             self.newArticles = false                             let realm = try! Realm()                             try! realm.write {                                 let articles = realm.objects(Article.self)                                 articles.setValue(true, forKey: "read")                                 var index = 0                                 for article in self.articleS {                                     article.read = true                                     self.articleS.insert(article, at:index)                                     index = index + 1                                 }                             }                         }                     }){                         Text("Mark all as read").lineLimit(2).font(Font.custom("Muli",size:13))                     }.buttonStyle(GradientButtonStyle()) This works as expected (meaning it is triggering action on click) but as soon as I change position of a navigationBarItem - the button stop working. struct GradientButtonStyle: ButtonStyle {     func makeBody(configuration: Self.Configuration) -> some View {         configuration.label             .frame(width: 105, height: 32, alignment: .center)             .foregroundColor(Color(UIColor.init(hexString: "#2D5AD6")))             .padding(.horizontal,5)             .background(Color(.white))             .cornerRadius(15.0)             .position(x:50,y:65)     } } Do you have a workaround how to make it working?
1
0
236
Sep ’20