Created
September 20, 2018 01:40
-
-
Save SergeyPetrachkov/0c6840835dedeeac49cf71847e98bcad to your computer and use it in GitHub Desktop.
GradientExample.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let gradientView = UIView(frame: CGRect(x: 0, y: self.textLabel.frame.maxY - 100, width: 375, height: 100)) | |
self.view.addSubview(gradientView) | |
let gradientLayer: CAGradientLayer = CAGradientLayer() | |
gradientLayer.frame = gradientView.bounds | |
// colors of your overlay. [0] - start color, [1] - end color | |
gradientLayer.colors = [UIColor(white: 1, alpha: 0.95).cgColor, UIColor(white: 1, alpha: 0.6).cgColor] | |
gradientLayer.startPoint = CGPoint(x: 0, y: 0) | |
gradientLayer.endPoint = CGPoint(x: 0, y: 1) | |
gradientView.layer.addSublayer(gradientLayer) | |
// rotate view 180 degrees | |
gradientView.transform = CGAffineTransform(rotationAngle: CGFloat.pi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment