I want to use NSAttributedString in my project, but when I\'m trying to set color, which isn\'t from the standard set (redColor, blackColor>
Since @Jaswanth Kumar asked, here's the Swift version from LSwift:
extension UIColor {
convenience init(rgb:UInt, alpha:CGFloat = 1.0) {
self.init(
red: CGFloat((rgb & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgb & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgb & 0x0000FF) / 255.0,
alpha: CGFloat(alpha)
)
}
}
Usage: let color = UIColor(rgb: 0x112233)