Skip to content

Easily use gradients in UIKit for iOS & tvOS

License

Notifications You must be signed in to change notification settings

arisprung18/GradientView

 
 

Repository files navigation

Gradient View

Easily use gradients in UIKit. Gradient View is a simple UIView wrapper around CGGradient.

Version Swift Version Carthage compatible CocoaPods compatible

Usage

// Initialize a gradient view
let gradientView = GradientView(frame: CGRect(x: 20, y: 20, width: 280, height: 280))

// Set the gradient colors
gradientView.colors = [.green, .yellow]

// Optionally set some locations
gradientView.locations = [0.8, 1.0]

// Optionally change the direction. The default is vertical.
gradientView.direction = .horizontal

// Add some borders too if you want
gradientView.topBorderColor = .red
gradientView.bottomBorderColor = .blue

// Add it as a subview in all of its awesome
view.addSubview(gradientView)

See the source for full documentation.

Example

Screenshot 1 Screenshot 2

Open up the included Xcode project for an example app.

Installation

Gradient View supports installation with Carthage or CocoaPods. You can also simply add GradientView.swift to your project if you’d prefer.

About

Easily use gradients in UIKit for iOS & tvOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 89.2%
  • Ruby 6.8%
  • Objective-C 4.0%