Creating Gradient Views in iOS

The really great things about the iOS development platform is the amount of customizability there is. There are a lot of different ways to customize the different UI components through code. It gives your code the power to directly effect the look of the UI, which is great. Since as a programmer you don’t really want to spend most of your time in Photoshop to make a button look really pretty 😬

Below you will find a great way of giving your views beautiful gradients.

The following code above results in:

GradientsExample

You can also adjust how the gradients line up as well. In the case above its across the diagonal, since we set “startPoint” and “endpoint” to (0,0) and (1,1). The top left hand corner is (0,0) and the bottom right hand corner is (1,1). Now if we set the “startPoint” to (0,0.5) and the “endPoint” to (1,0.5), we get the following effect:

GradientsExample2

Cooool right ? 😎

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s