Linus Torvalds, the creator of the massively popular Linux operating system, once said “talk is cheap; show me the code.” What he was trying to say in his inimitable way is that seeing code that solves a problem well is often the most important thing in our industry – it’s important to talk about problems and to explore them thoroughly on a conceptual level, but ultimately writing code that solves the problem is what makes products ship.
I use storyboards for most projects I teach – they are easier for beginners to learn, they give us the ability to see how a design looks as we’re building it, and they can even show you previews across multiple devices and orientations at the same time.
However, in this project we’re going to build the user interface entirely in code. There will still be a storyboard, but we’re not going to touch it – we’ll create our labels, buttons, and Auto Layout constraints entirely in Swift.
This is our “show me the code” moment: we’re going to look at exactly how to build complex iOS layouts programmatically so that everything is entirely under your control. It’s not hard to do, but it does take a lot of time – we need to create, configure, and place every view by hand. However, I think you’ll learn a lot from the experience, because after today I think you’ll know for sure whether you prefer using storyboards or creating UI in code!
Today you have two topics to work through, and you’ll learn about text alignment, layout margins,
UIFont, and more.
Once you’re done, there’s something I’d like you to keep in mind: whether you prefer making user interfaces in storyboards or programmatically, it’s important you know how to do both. It’s one thing having your preference, but when you join a company you need to be able to solve problems as a team.
Need help? Tweet me @twostraws!
SPONSORED Join a FREE crash course for iOS devs who want to become complete senior developers — from October 18th to 24th. Learn how to apply iOS app architecture patterns through a series of lectures and practical coding sessions.
Link copied to your pasteboard.