O'Reilly logo

Swift by Example by Giordano Scalzo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Completing the UI

Although the views are in the correct place, we need to implement all the components.

CurrentWeatherView

First of all, we need to import the fonts' frameworks:

import LatoFont
import WeatherIconsKit

The former is the font we've already used in the TodoList app; the latter is similar to AwesomeKit, and it contains a series of icons related to the weather:

    private let cityLbl = UILabel()
    private let maxTempLbl = UILabel()
    private let minTempLbl = UILabel()
    private let iconLbl = UILabel()
    private let weatherLbl = UILabel()
    private let currentTempLbl = UILabel()

We simply add all the labels and lay them out:

 func layoutView(){ layout(self) { view in view.height == 160 } layout(iconLbl) { view in view.top == view.superview!.top view.left ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required