swiftuikitstoryboarduibarbuttonitemiboutlet

Set UIBarButtonItem's background color working with Storyboard swift


I know that this has been asked really often, but I couldn't find anything about doing this with an IBOutlet.

I have already found some code how to set the background color of an UIBarButtonItem when you create it with code. But I have implemented many connections from the UIBarButtonItem I created in the Storyboard.

Is it possible to set the background color and the corner radius of a Storyboard-UIBarButtonItem? And if it is, please write me how.

Thanks and sorry for my English.


Solution

  • First, drag and drop a UIButton to UINavigationBar. Then from Document Outline select the UIButton which is a child of UIBarButtonItem.

    enter image description here

    Now go to Identity Inspector from the right panel. Here in User Defined Runtime Attributes section you can set backgroundColor, cornerRadius etc. of UIButton.

    enter image description here

    But the modification does not reflect in Storyboard. Run your project and you can see the changes.

    enter image description here