miércoles, 28 de septiembre de 2016

Swift: Tex with various colors or formats

        let differentColorText: String = "60 seconds"
        
        let fullText: NSString = "Match when you engage\nmore than 60 seconds in\na conversation."
        
        let range: NSRange = fullText.rangeOfString(differentColorText)
        
        let string: NSMutableAttributedString = NSMutableAttributedString(string: "Match when you engage\nmore than 60 seconds in\na conversation.")
        string.addAttribute(NSForegroundColorAttributeName, value: UIColor.lightGrayColor(), range: range)
        

        titleLabel.attributedText = string

No hay comentarios:

Publicar un comentario