Friday, February 10, 2017

How to Get Hex String to Color in Swift

2 comments :
reate A Categeory Class
//  UIolor+CustomUIColor.swift

extension UIColor
{
    
    convenience init(hex: Int)
    {
        self.init(hex: hex, alpha: 1)
    }
    convenience init(hex: Int, alpha: Double)
    {
        self.init(
            red: CGFloat((hex >> 16) & 0xff) / 255,
            green: CGFloat((hex >> 8) & 0xff) / 255,
            blue: CGFloat(hex & 0xff) / 255,
            alpha: CGFloat(alpha))
    }

}


Usage :
        self.timeLabel!.textColor = UIColor(hex: 0x626B6F)

2 comments :

  1. If you're trying to lose kilograms then you need to try this brand new custom keto diet.

    To create this keto diet service, licensed nutritionists, personal trainers, and cooks have united to provide keto meal plans that are productive, suitable, economically-efficient, and enjoyable.

    Since their first launch in 2019, hundreds of clients have already transformed their figure and well-being with the benefits a professional keto diet can give.

    Speaking of benefits; clicking this link, you'll discover eight scientifically-confirmed ones offered by the keto diet.

    ReplyDelete