In my code I hide various UIButtons on my page using UIButton.hidden if the data source for that button does not contain a value.
For example a business may or may not have a URL. In my app, if a business has a website, I load it into the title of a button so the use can click on the button and be taken to the business' website. If the business does not have a website, I hide the button.
The challenge is that the button appears to take up screen real-estate even when it is hidden. I have even tried the following code and the button still consumes space on the page:
btnURL.frame.size.height = 0
btnURL.frame.size.width = 0
btnURL.setTitle("", forState: .Normal)
btnURL.hidden = true
I had the same problem, I add button width constrain and set it to zero:
btnURLWidth.constant = 0
P.S. To hide label you can set zero font.