How would I in UIKit in iOS 26 put e.g. a login button on the trailing side of a navigationbar?

Asked on 2025-11-12

1 search

In iOS 26, to place a login button on the trailing side of a navigation bar in a UIKit app, you can use the UINavigationItem to manage the bar button items. You can assign your login button as a right bar button item to achieve this. Here's a brief overview of how you can do it:

  1. Create a Bar Button Item: Initialize a UIBarButtonItem with your login button.

  2. Assign to Navigation Item: Set this bar button item to the rightBarButtonItems property of your UINavigationItem.

Here's a simple code example:

let loginButton = UIBarButtonItem(title: "Login", style: .plain, target: self, action: #selector(loginAction))
self.navigationItem.rightBarButtonItem = loginButton

This will place the login button on the trailing side of the navigation bar. The system will automatically handle the layout and appearance, including the new glass appearance introduced in iOS 26.

For more details on navigation bars and toolbars in the new design, you can refer to the session Build a UIKit app with the new design.