Last active
May 27, 2019 08:54
-
-
Save yusufozgul/834a0522249aefbda9b599e1424cda05 to your computer and use it in GitHub Desktop.
Gradient Color
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
// Bir view oluşturalım. | |
let gradientView = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) | |
// gradient layer oluşturuyoruz | |
let gradient = CAGradientLayer() | |
// gradient'imiz için renkleri array halinde ekliyoruz. | |
gradient.colors = [UIColor.red.cgColor, UIColor.blue.cgColor] | |
// soldan sağa gradient olması | |
gradient.startPoint = CGPoint(x: 0.0, y: 0.0) | |
gradient.endPoint = CGPoint(x: 1.0, y: 0.0) | |
gradient.frame = gradientView.bounds | |
gradientView.layer.addSublayer(gradient) | |
gradientView.center = view.center | |
view.addSubview(gradientView) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment