Last active
May 27, 2019 09:15
-
-
Save yusufozgul/1289e7a59342bb5471e4c8902b575344 to your computer and use it in GitHub Desktop.
Gradient color for label
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
// Label oluşturup gradient view'umuza ekliyoruz. | |
let gradientLabel = UILabel(frame: view.bounds) | |
// Tha magic! Burada gradientLabel'ı view'a maske olarak geçiriyoruz. | |
view.mask = gradientLabel | |
gradientLabel.text = "Hello World" | |
gradientLabel.font = UIFont.boldSystemFont(ofSize: 30) | |
gradientLabel.textAlignment = .center | |
gradientView.addSubview(gradientLabel) | |
// Yeni View oluşturup gradientView'umuzu ekledik. | |
let gradientLabelBackground = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) | |
view.addSubview(gradientLabelBackground) | |
gradientLabelBackground.addSubview(gradientView) | |
// Burası tüm işimizi yapan yer :) View'umuza bir mask ekledik. | |
gradientLabelBackground.mask = gradientLabel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment