Swiftpack.co - Package - robinlieb/GradientViewExtension

GradientViewExtension

This package extends UIView to set a gradient background.

Getting Started

Installing

Swift Package Manager

To include GradientViewExtension into a Swift Package Manger package add the dependencies value in your Package.swift:

dependencies: [
    .package(url: "https://github.com/robinlieb/GradientViewExtension.git", from: "0.0.1")
]

CocoaPods

To include GradientViewExtension into your CocoaPods project add it into your Podfile:

pod 'GradientViewExtension', '~> 0.0.1'

Usage

By default the extension draws an axial gradient.

var view = UIView()
view.setGradientBackground(startColor: .black, endColor: .white)

You can also set the gradient type explicitly. Possible values are axial, radial and conic.

var view = UIView()
view.setGradientBackground(startColor: .black, endColor: .white, gradientType: .radial)

This extension can be used by all subclasses of UIView, i.g. UIButton:

var button = UIButton()
view.setGradientBackground(startColor: .black, endColor: .white)

Requirements

  • iOS 12.0+
  • Xcode 10.2+
  • Swift 5+

License

Licensed under MIT license, see LICENSE.

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 0