(616) 371-1037

[email protected]

Gradient backgrounds in Xamarin iOS

April 23, 2018 - Valeriy Kovalenko

No Comments

Did you notice that graphic designers love gradients? It was a trend in mobile designs that started in 2017 and now it’s getting even more popular. Let me share a few useful code snippets that will help you to make awesome looking iOS applications with Xamarin.

First the gradient itself. We’re going to use a radial gradient.

Now to explain the code above. As the center, I took an arbitrary point that provides good results. In this case, it’s 1/3 of the view width and 90 points from the top of the screen. To make sure that the gradient covers the whole view, we need to calculate a distance to the farthest corner.

Now the next bit of code:

We have a simple extension method that creates an UIImage filled with a given color. We’re going to use this extension to make the navigation bar semi-transparent. Let’s put everything together now.


A storyboard with a navigation controller and a single view controller. The view controller contains a view with Custom Class set to UIGradientView.

And here we use the extension method created above to make the navigation bar semi-transparent. Let’s take a look at the results!


Beautiful, isn’t it? There is an awesome resource with a lot of cool gradients to help you start at uigradients.com. Happy coding!

Valeriy Kovalenko

Leave a comment

Your email address will not be published. Required fields are marked *