I wanted to reposition the left and right buttons of the Navigation Bar such that there are three and they're equally spaced. To do so I looked at this question for reference: stackover flow - How to edit position of navigation bar button. I managed to solve it by my self by changing the size of the frames for the buttons so it looks like the following:
My Navigation Bar (Black and white boxes are buttons in the navigation bar)
However, the post said that if I were to break the HIG then my application will be removed from the app store. So I was wondering to what extent is this true (as I didnt have to break Xcode to achieve what I wanted) and if what I have now is safe.
Here is the code I have :
viewDidLoad() {
let todolistButton = UIButton(type: .system)
todolistButton.backgroundColor = UIColor.black
todolistButton.frame = CGRect.init(x: 0, y: 0, width: (view.frame.width-50)/3, height: 44)
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: todolistButton)
let scheduleButton = UIButton(type: .system)
scheduleButton.backgroundColor = UIColor.black
scheduleButton.frame = CGRect.init(x: 0, y: 0, width: (view.frame.width-50)/3, height: 44)
let calendarButton = UIButton(type: .system)
calendarButton.backgroundColor = UIColor.white
calendarButton.frame = CGRect.init(x: 0, y: 0, width: ((view.frame.width-50)/3)+2, height: 44)
navigationItem.rightBarButtonItems = [UIBarButtonItem(customView: scheduleButton), UIBarButtonItem(customView: calendarButton)]
}
Thank you!