6

In iOS 13 many apps have the navigationBarItems aligned horizontally with the navigationBarTitle.

WHAT I WANT

TO ACHIEVE enter image description here

RESULTS I GOT

RESULT 1 enter image description here

RESULT 2 enter image description here

How do you achieve the same result in SwiftUI?

I have tried using some .top padding but when you scroll the "+" button does not move.

Thanks!

Artur Marchetto
  • 646
  • 1
  • 5
  • 17
  • The short answer is you can't. The examples you've shown are Apple apps and they haven't exposed a way to do this for 3rd party developers in UIKit-land or SwiftUI. If these were available, the first clue would be they'd appear on `UINavigationItem` or `UINavigationBar` but they do not. My guess is this will get exposed sometime in the future. – Procrastin8 Aug 27 '19 at 22:11
  • @Procrastin8, not to disagree - I'm not - but this is clearly tagged `SwiftUI` along with mentioning it (in bold) in the question. Why bring up `UINavigationItem` or `UINavbigationBar`, which are both part of `UIKit`? –  Aug 28 '19 at 01:18
  • ext comment, to @Arthur. This really isn't a good question. Three links, no code, and very vague. (Is your **specific** issue that the "+" button doesn't move or something related to a `NavigationView`?) Seriously, don't link to your results - show us code, tell us what is wrong with the results, and tell us something we can actually duplicate. As is? Hard to say what the issue (or solution) is. –  Aug 28 '19 at 01:23
  • @dfd I think Procrastin8 mentioned UINavigationItem and other UIKit elements beucase at the moment, NavigationView is implemented using the old UIKit elements. In fact if you want to change some properties of the NavigationView, you have to customize the UINavigationBar.appereance. In the future apple should give use ways to customize NavigationView without using the UIKit elements. – Artur Marchetto Aug 28 '19 at 06:21
  • @dfd There was no need to show any code because I could not find any way to implement what apple has achieved. Anyone who has used SwiftUI knows what padding is. Obviously the problem is not with the "+" button, but with ANY navigationBarItem you want to align horizontally with the title !! – Artur Marchetto Aug 28 '19 at 06:23
  • does the answer from this question help? https://stackoverflow.com/questions/57338785/swiftui-custom-navigation-bar-with-list – yawnobleix Aug 28 '19 at 06:59
  • @yawnobleix not really.. thank you anyway! – Artur Marchetto Aug 28 '19 at 07:07

0 Answers0