UIKit and Constraints

Alright, so the long weekend is over and it’s time to go back to work (I don’t mean studying.. I mean work-work. In my case, telework this week.) But, thankfully, I finished up everything work-work related before lunchtime and so I was able to “hit the books.”

Continuing with the previous section, I am now at the UIKit intro lesson.

Through out this brief tutorial/intro we learned about storyboarding which included concepts such as constraints on a view. In this instance, a view, was simply an orange box in the middle of our first storyboard. Sean really took time to make sure that the idea of constraints really hit home here; It worked for me.

This orange box was drawn into the upper half of our storyboard.. not quite all the way to the top of the screen but pretty close. In Xcode, you can display what your app would look like on what’s called a simulator (which is a simulated version of a device) right inside of the Xcode app. It’s pretty cool, to be honest.. supremely useful I imagine. Anyhow, every device is different as far as the dimensions and resolutions are concerned. The aspect ratios may not be the same. Imagine having to individually tweak every facet or an app PER device. That would be a nightmare! That is where Constraints come in.

With a constraint.. you are effectively setting up rules that the different elements of your storyboard have to follow.. regardless of device. So, we were able to set up multiple constraints for our orange box. We set 1 constraint that made the top of the orange box begin 50 points away from the safe area. I bolded those items for a reason.. here comes the detour..

Detour (Oooh bolded and italicized!): Points and Safe Areas. Ok so instead of pixels we’re dealing in a measurement of points. It’s a relative unit of measurement that doesn’t equate to a pixel because all devices have different resolutions. Totally makes sense to go that route for the sake of constraints. And a Safe Area relates to the exclusive of the area that houses the notch. Maybe I should include a picture for this. Here we go:

Safe areas in the Calendar app

Hopefully that clears it up a bit. You know.. since I’m still super new to this blogging thing. I wonder if there’s an issue with me just ripping images from google images. Hopefully there’s no bridge for me to cross. I’ll try to use images more often to break up my ramblings.

Storyboard or Code

It feels kind of weird centering another title but whatever.. it’s fine. Sean, rounded out the iOS Dev Fundamentals section with a quick video about his take on the debate surrounding whether to use storyboards for your interface or to do it programmatically. I don’t know enough about either to weigh in here but he goes on to say that it essentially comes down to preference. He personally prefers storyboards when the interface/screen/menu is very simplistic but when more complexity is involved he prefers to build it programmatically. As he says, “It’s on a spectrum.” Obviously, I’ll learn more about both as I go forward in this course and I have a feeling that I’m going to prefer a mix of both with a bit of a lean towards the programmatic side.. I just really like typing. Speaking of which, now that I have my MBP up on a nice stand, I need to look into buying an external keyboard and mouse. It’s tough because I really like the way this keyboard feels and I love the track pad.. decisions, decisions.

Alright.. next up.. FizzBuzz – A Rite of Passage (Sounds so daunting)

Leave a comment