iOS tips: How to lock UI element properties in storyboard iOS ?

Suppose if you want to restrict somebody working on the same project to change the properties of a UI component in storyboard, or if you want to restrict yourself to change the properties by mistake while dealing with the storyboards, wouldn’t that be awesome?? Yes, you can do this in storyboard. I will tell you how.

Image for post
Image for post
stocksnap.io

Just do the following:

Image for post
Image for post
  1. Click on the UI element you want to lock.
  2. Click on the Identity inspector (check the image above).
  3. Under the Document section, click on the Lock drop down menu and select what is required. Every option is self explanatory .
Document lock options
  • Inherited /Nothing is the default option selected. Here it will use its superviews option.
  • All Properties will lock all the properties so that all the properties in the attributes inspector remains unchangeable.

Select the option “All properties”. Then goto the attributes inspector and try to change any property. ex: I tried to change the title colour of the button here and a lock icon is displayed as shown in the image below.

Image for post
Image for post
Lock icon

NOTE: This is the lock option for the document. This means that the UI components properties cannot be edited from storyboard. It can be changed through code by using IBOutlets.

If you want to lock all the views in a ViewController, you can select the upper most view in the view hierarchy (ie; the content view) and change the lock option to All Properties. If all the subviews lock option is inherited, this will work. Otherwise, it will not.

Thats it.!!

Enjoy!!

If you enjoyed reading this post, please share and give some clapps so others can find it 👏👏👏👏👏 !!!!

You can follow me on Medium for fresh articles. Also, connect with me on LinkedIn. Also follow my facebook page on swift: iosswiftblogger.

If you have any comment, question, or recommendation, feel free to post them in the comment section below!

Written by

iOS and tvOS developer, dreamer, photographer 🤨

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store