What is the difference between navigationBarTitle and navigationTitle modifiers in SwiftUI 2.0?

。_饼干妹妹 提交于 2020-12-31 15:00:41

问题


Learning all the new SwiftUI 2.0 changes but came across .navigationTitle which seems to work almost exactly like .navigationBarTitle. I looked at the WWDC 2020 videos and found one video where it was mentioned as being used to distinguish tab titles in MacOS? But not sure if it I should use it now instead of .navigationBarTitle in iOS? Also the Apple documentation is not clear about the differences between the two..

So my question is, what are the exact differences and how would you use them in iOS/MacOS?


回答1:


The navigationBarTitle is just deprecated and renamed to navigationTitle:

@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(macOS, unavailable)
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "navigationTitle(_:)")
public func navigationBarTitle(_ title: Text) -> some View


来源:https://stackoverflow.com/questions/63735226/what-is-the-difference-between-navigationbartitle-and-navigationtitle-modifiers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!