Add Gradient in UIView using Extension in Swift 3.0

Save

UIView Extension of Gradient

The extension is a great concept in swift in swift you can add your function is already predefined classes in swift 3.0 like String, UIView, UIColor etc.A while creating an extension you can write it anywhere in your project.To create a gradient extension you have to create an extension of UIView class.The main benefit of extension is that it will reduce many of your code lines like you have to use the gradient 5 times in your project so you have to write the same code 5 times in your project while creating an extension you have to write it only once it will also save the application memory.Example to create an extension:-

how to use Extension:- 

Add Transparency To GRADIENT:-

If you want to add transparency to the gradient, then you have to change the alpha of your colors:-

 

. . .

Leave a Comment

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


Be the first to comment.

css.php

Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.

Osama
Talk to Sales

Global

Live Chat
Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home