Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change UIToolbar height? [duplicate]

I want to change the height of the UIToolbar in Navigation Controller, but I am not able to do so in swift with Xcode 7.3 and iOS 9. I have tried to set frame with CGRectMake at viewDidLoad, but it didn't work. Also tried to init a custom UIToolbar(), but the height remain the same.

Edit:

As per one of the answers, I have tried selected toolbar, press control and select the toolbar again, but what I got is shown in below screenshot instead:

Screenshot

like image 813
Victor Leung Avatar asked Aug 22 '16 08:08

Victor Leung


1 Answers

There are 2 options depending on whether you are using Storyboards or not.

Option 1: Using Storyboard

1) Go to your Storyboard and from your selected Toolbar press and hold Ctrl and click on your Toolbar again as if you were assigning an IBAction. Then you will get the following:

(Sorry for the quality of the first image; had to take a snap with my phone because I couldn't make a screenshot while holding ctrl)

enter image description here enter image description here

2) Then press on height to get the constraint and change the value:

enter image description here

Option 2: Using Swift for e.g. 55 px height

 yourToolBar.frame = CGRect(x: 0, y: view.frame.size.height - 55, width: view.frame.size.width, height: 55)
like image 138
tech4242 Avatar answered Sep 22 '22 15:09

tech4242