简体   繁体   中英

Add rightBarButtonItem on second place Swift

I want to add rightBarButtonItem directly to the position of second place because I already have slider menu button on the right side of navigation bar(which is placed by third party framework and I don't have control over it). The following is the screenshot for the same with black area where I want second button for notifications.

在此处输入图像描述

Following is the code using which add it to top of slider menu button:-

let backButton = UIButton(type: UIButton.ButtonType.custom)
backButton.setImage(UIImage(named: "menulist"), for: UIControl.State())
backButton.frame=CGRect(x: 0, y: 0, width: 25, height: 25)
let rightbarButton = UIBarButtonItem(customView: backButton)
self.navigationItem.rightBarButtonItem = rightbarButton

Slider menu is a third party framework so I don't have any idea how to achieve it.

Please help and suggest some workaround.

You can append your new item like:

navigationItem.rightBarButtonItems?.append(newButton)

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