简体   繁体   中英

How to format two UIBarButtonItems next to each other on the right?

I'm trying to format two UIBarButtonItems so that they are right next to each other in the upper right corner. I have already tried changing the UI Edge Insets, but it didn't really move the icons around. Screenshot of current UI bar

lazy var profileButton = UIBarButtonItem(
    image: UIImage(named: "account"),
    style: .plain,
    target: self,
    action: #selector(displayAccountViewController(sender:))
)

lazy var followFriendsButton = UIBarButtonItem(
    image: UIImage(named: "follow"),
    style: .plain,
    target: self,
    action: #selector(displayFollowFriendsViewController(sender:))
)

override func viewDidLoad() {
    super.viewDidLoad()
    navigationItem.title = "Review Feed"

    tableView.register(ReviewFeedCell.self, forCellReuseIdentifier: cellReuseIdentifier)
    tableView.separatorStyle = .none

    navigationItem.rightBarButtonItems = [profileButton, followFriendsButton]

    NotificationCenter.default.addObserver(self, selector: #selector(loadData), name: ShowCollector.updateNotification, object: nil)
}

You should change size of your images.

Refer to Apple design guideline

在此处输入图像描述 :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM