/ iOS

A Vibrant Background Image View in Swift

A while back I wrote about how you could make the transition from Launch Image to root view controller look smooth with a background image as large as the iPhone 6 Plus resolution.

I recently found myself using the background on a few screens for logging in, registering an account and changing settings. I added blur and vibrancy effects to the background so it didn't take focus, merely adding vibrancy. (which didn't work as expected on my iPhone 6.

Since it was quite a chunk of code to make it appear full screen and add effects I sub classed the code to be more re-usable and exposed a property for the container view the consumer can set to add other UI elements.

One little detail I really like in Swift is the simplicity of cleverness you can add to properties. In this view I don't want to be responsible for exposing getters and setters just to add the containerViewas subview when a new one is assigned. The willSet observer is just what I needed.

See for yourself.