Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swapping UIViews for UIButtons in storyboard

I am guessing that this isn't possible. I spent about 2 hours laying out my views in autolayout. When I started coding, I realized that half of the views I laid out should actually be UIButtons. Is there anyway to just select a UIView and somehow change it to a UIButton? I tried typing in UIButtonto the class field. But it didn't change all the attributes like as if I had dropped a UIButton on the storyboard.

like image 953
Chase Roberts Avatar asked Sep 29 '22 14:09

Chase Roberts


1 Answers

You can open the Storyboard as source (right click on the Storyboard file and select Open As Source Code). Then use Find Menu's Find and Replace... to make changes. For example, change <view> to <button>. Save the file. After any desired text editing, right click on the Storyboard file again and Open As Interface Builder - Storyboard to restore the normal Storyboard view.

This is particularly useful when you want to change one color to another, or a to change a font name throughout a Storyboard. Just be careful, Storyboards can be rather fragile as text.

like image 142
jbbenni Avatar answered Oct 08 '22 08:10

jbbenni