Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refactor UIButton to UILabel in storyboard

I've a view in my storyboard with a lot of UIButton with constraints.

Is there a way to transform these buttons to labels without removing each button and create a label with constraints?

like image 859
Luca Davanzo Avatar asked Dec 18 '14 11:12

Luca Davanzo


1 Answers

  1. UIButton actually contains a UILabel for displaying its titleLabel. So You can set the button UserInteractionEnabled: property to NO.

  2. UIButton may have border color. So set the border color as clear color.

  3. Make the UIButton as custom type.

    As you need to reconfigure the constrains again if you added the labels, you can go for the above solution.

Reason for couldn't change in IB/Storyboard:

You have dragged the UIButton from the library to your view. Even you try to change the class name to UILabel or its subclass it won't change the class name.

because UILabel is just a UIView type, Where as UIButton is UIControl type.

That's why you couldn't change the UIButton class name to UILabel or Subclass of UILabel in IB.

Updates:

No Guarantee/Not Recommended on upcoming XCode release

enter image description hereenter image description hereenter image description hereenter image description hereenter image description here

like image 73
Vijay-Apple-Dev.blogspot.com Avatar answered Oct 31 '22 13:10

Vijay-Apple-Dev.blogspot.com