/ iOS

Easily display different formats of your logo in Swift

I constantly make very small UI sub classes in my iOS apps to make it easy to display a certain type of label, button or text field.

I'm using Swift in my current project and when I wanted to make a sub class of UIImageView that displays a logo, I thought I'd try to get clever with enums in Swift.

The logo comes in different formats and it's practical to easily be able to render it in different sizes.

I wrapped the code in an Enum called LogoView:

To use it, you'll need the protocol and extension I called UIViewConvertible included with the gist above.

The following code, will produce the view shown below:

var l0 = LogoView.Large().View
l0.center = CGPointMake(view.center.x, 150)
var l1 = LogoView.Default().View
l1.center = CGPointMake(view.center.x, 300)
var l2 = LogoView.Symbol().View
l2.center = CGPointMake(view.center.x, 400)