HVGradientView is a pod which helps to add gradient effect to any UIVIew. It is written in Swift 4.
- Open podfile in your project.
- Add the following into your podfile:
pod ‘HVGradientView’, :git => ‘https://github.com/Harsh061/HVGradientView.git’, :tag => ‘1.0.0’
- Run the command:
pod install
- Open the project. Drag a UIView into storyboard.
- Go the the identity inspector and in the class field, type HVGradientView instead of UIView.
- Open the viewcontroller and create an outlet of the view.
@IBOutlet weak var gradientView: HVGradientView!
- Set your custom properties like topColor, bottomColor, CornerRadius and Gradient direction.
- Gradient direction can be:
private func setupGradientView() {
gradView.translatesAutoresizingMaskIntoConstraints = false
gradView.topColor = UIColor.yellow
gradView.bottomColor = UIColor.red
gradView.gradientDirection = .horizontal
}