12 Weeks as a iOS Developer Intern — Week Nine
Week 9 was quite exciting! A project I contributed to was released and of course I also learned new things and I will be sharing a little bit of it here:
Project Release
A consumer facing iPad kiosk system I contributed to, was officially released in San Francisco! The app is for ordering food for dine-in/ pick-up for a fast/casual chain 😊
It’s just so amazing to build things that consumers use and I live for that.
I can’t wait till the kiosk system is expanded to other cities! I would also love to make a trip to San Francisco to check the kiosk out in the wild😍
Cheers to the successful release and to many more 🍻!
Animating Components In A StackView
I had to animate an error UILabel to appear with an error message underneath the textField if the input was invalid. The error label should come from under the invalid input and animate back up and away after two seconds. In the example above, the email field is incorrect thus the error UILabel should animate down and disappear after two seconds.
Each of the fields is a reusable custom UIView. State is managed in each field to validate the input.
- The errorLabel is inside the custom UIView and is initially hidden and constrained to the edges of the custom UIView
- When input is invalid,the height of the custom UIView is updated to 2x the initial height
- UIView.animate is used to unhide the error label and animate the errorLabel to the bottom of the UIView
When expanding different components inside of a stackView, the distribution must be set to the following or it won’t expand and push the below view of the stackview down
stackView.distribution = .fillProportionately
isHidden
When hiding a UIView and unhiding it, if you think about it, it seems like it is just changing the alpha. (0 opacity would show nothing whereas an opacity of 1 is fully opaque and visible. Though isHidden and changing the alpha opacity cannot be used in conjunction to hide and unhide a view.
For example if a UIView is hidden with .isHidden, a .alpha change will not unhide it.
myView.isHidden = true
myView.alpha = 1 . //this will not unhide the view//The below will hide & unhidemyView.isHidden = true
myView.isHidden = falsemyView.alpha = 0
myView.alpha = 1
Padding on UILabel
I had to have some text with padding and a background color that spanned from the left edge of the screen all the way to the other side & edge of the screen.
There is no built in customizable padding/insets on a UILabel.
The obvious answer is to put the UILabel inside of a container UIView and to constrain the label so that it has padding inside of the container view.
Though I could not get this to work for a stackView that was composed of a reusable custom UIView. The order of the views was quite odd. Even though the container view was added before the error UILabel and the error label added to the container, it appeared on top of the UILabel, completely obscuring the UILabel.
I found this intense padding extension on UILabel on stackOverflow that worked:
That’s all for Week 9~
Thank you for reading!
Read about week 7 and 8 as an iOS developer intern here
Show your support with 👏 claps below, follow me on my iOS developer journey 😊 on Twitter