In UIKit it is very straight-forward to set a background on any view — in SwiftUI it is a little bit trickier

Multi-colored background behind bike.
Photo by Autumn Studio on Unsplash

The Basics

Let’s start with a simple view:

Colored background

In this article I will explain to you two ways to add a colored background to our view:

1. Using ZStack

The first approach consists of creating a ZStack structure where the color background will be the second layer behind the actual content:

2. Using the .overlay view modifier

The second approach consists of adding the selected color as the main element, and then a .overlay


Combine to the rescue

Data
Photo by Markus Spiske on Unsplash.

What Is a Validation System?

A validation system allows an app to evaluate a user input stream and decide if that data is valid based on some rules.


SwiftUI

Custom placeholders for making the wait more pleasant


SwiftUI

A state-based approach in SwiftUI

Author: Pablo Blanco

Swift

How to create a great structure for environment configuration in Swift

Photo by Jarvik Joshi on Unsplash

1. Endpoint structure

We start by creating an Endpoint struct declared like this:

2. App endpoints

Our app has two different features:

  • addUser: Add a new user

3. Environment configuration

To have a clear understanding of the environments…


Photo by Pavel Anoshin on Unsplash
A sample request for getting users


Photo by Lily Li on Unsplash
  • Hardcoded values: Colors, paddings, etc. are set directly on the view. If in…


Photo by Kristopher Roller on Unsplash
  1. Code your solution
  2. Submit the code

1. Prepare the test

Master the coding platform

Take some moments to know the coding platform. Please, don’t skip tutorials. Some important things you should know before starting code are:

  • How to submit your solution
  • How to check the remaining time
  • How to select the programming language…


The bad test case

This test was recorded with the Recording feature from XCode. The actions made by the user are in-code commented:

func test1() {    // 1. The user taps in a textfield
app.textfields["Send something..."].tap()
// 2. The user types the text “Hello
app.textfields["Send something..."].type("Hello")

Pablo Blanco

Senior iOS Engineer @ Expedia Group

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store