Last active
December 19, 2015 07:17
-
-
Save taji-taji/27dd1104c749aa9f59d6 to your computer and use it in GitHub Desktop.
【Swift】作成済みのUIColorのalpha値のみを変えたい ref: http://qiita.com/taji-taji/items/f3681d15a5f6d7a79e06
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 redColor = UIColor.redColor() | |
let transparentRedColor = redColor.colorWithAlphaComponent(0.6) |
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 redColor = UIColor.redColor() | |
let transparentRedColor = redColor.setAlpha(alpha: 0.6) |
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
import UIKit | |
extension UIColor { | |
func setAlpha(alpha a: CGFloat) -> UIColor { | |
var red: CGFloat = 1.0 | |
var green: CGFloat = 1.0 | |
var blue: CGFloat = 1.0 | |
var alpha: CGFloat = 1.0 | |
self.getRed(&red, green: &green, blue: &blue, alpha: &alpha) | |
return UIColor(red: red, green: green, blue: blue, alpha: a) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment