Implementing the UI
A UI that is as complicated as the one required can be really difficult to implement if we don't take the correct precautions.
A good way to minimize the complexity is to split the problem into more manageable sub-problems, so we'll define three sub-views: CurrentWeatherView, HourlyForecastView, and DailyForecastView. We'll implement them as separate entities. The following screenshot shows the view's structure:
The UI in blocks
As we just said, we implement the UI by creating three custom views, whose size and position we are temporarily hardcoding.
Let's start with CurrentWeatherView, adding it to PrettyWeatherViewController
:
Get Swift 2 By Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.