Created
March 8, 2019 09:09
-
-
Save muhlenXi/206cba25a2d56a3642d2919b5903e592 to your computer and use it in GitHub Desktop.
给视图添加渐变效果
This file contains 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 contentView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 200)) | |
let gradientLayer = CAGradientLayer() | |
gradientLayer.frame = self.bounds | |
gradientLayer.colors = [UIColor.white.withAlphaComponent(0).cgColor, UIColor.white.cgColor] | |
gradientLayer.startPoint = CGPoint(x: 0, y: 0) | |
gradientLayer.endPoint = CGPoint(x: 0, y: 0.5) | |
contentView.layer.addSublayer(gradientLayer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment