So there has been a lot of debate on the internet as well as in programmers about using Storyboard to design UI or designing the view Programmatically. Well if you look at the Storyboard Interface Builder you will be impressed. As we can clearly see Apple has put a lot of effort into developing the storyboard’s UI for us. It’s quite handy.
I had my fair share of using both options for creating UI. So ill start by stating the pro parts of both options.
User Friendly: Storyboard is very easy to use and very user-friendly for developers. The first time I started iOS app development and used Storyboard it was so much fun and easy. Way to impressive than Android Studio Layout Editor. It was so easy to navigate around and integrate objects into a screen. All I had to do was just drag-drop the item into the design. I could change the colour, the font, the text, the title etc. So all I had to do was some clicks and some drag and drop and the result is achieved. The same would take lines of code to achieve programmatically.
See what you Edit: This is kind one of the most important aspects of why people choose Storyboard. It gives us a visual representation of what we are editing and how it will come out to be. You can figure out exactly where the button is going or where the text must go, what the colour should be etc. You can add constraints to adjust the size of the objects. Their placements, everything.
Multiple Screen: In Storyboard we can create multiple views that are required in our app and navigate through these views with transition animation.
Control: When we use code to build the UI, we get complete control over the UI design. Whatever we can achieve using Storyboard can be achieved over coding, even better. You completely understand how the UI works.
Changes: When we use a storyboard and have to do changes to different views or multiple places, it takes a lot of work as you have to do all the changes one by one. But when we design UI programmatically, change on some lines of code and you achieved the changes. You can even keep all the UI elements in one place and can change the UI with a simple code change. It’s easy to change the UI by code than by storyboard as I usually tend to forget to edit the storyboard or miss out on some elements.
Reusability: We agree that it takes a lot of time to create UI from code. But once the element is ready we can reuse the code to create the same UI again. We can just copy and paste the code and re-create the UI element. And when we see the design of an app, mostly the design of the element is kept constant. Hence we can reuse the code.
Clutter: So story board is all fine and good at the start. But when our app grows and our views increase, our storyboard gets cluttered. And we find a lot of views with their segues used for navigation. It makes it hard to find our view of where we want to do the changes.
Here you can see when the views increase the clutterness starts to increase.
Multiple Developers: When our development is just done by one person we can use whatever option we like to build our app. But when multiple users come into development we have to look for some of the factors. We should make sure the technology we are using is compatible with all our developers. And most important, merging the code.
When we code the UI programmatically it’s easy for us to merge the code over GitHub and everyone can use the changed code. But when we use storyboard it gets hard for other developers to implement the UI design changes into our projects.
So with the overall pros of programming, I finally decided to switch to creating UI programmatically and it actually helped me in many ways.
Each of the options has its pros and cons and it’s hard for us to decide. So whatever suits the best of the situation, we will use that the most.
Please share your views, and also let me know what option would you use to design the UI.