miércoles, 28 de septiembre de 2016

Swift: Add icon to label

let attachment: NSTextAttachment = NSTextAttachment()
        attachment.image = UIImage(named: "information icon")
        attachment.bounds = CGRect(x: 0, y: -5, width: attachment.image!.size.width, height: attachment.image!.size.height)
        
        let attachmentString: NSAttributedString = NSAttributedString(attachment: attachment)
        let attributedText: NSMutableAttributedString = NSMutableAttributedString()
        attributedText.append(attachmentString)
        attributedText.append(NSAttributedString(string: " We will never post anything to Facebook"))
        

        informationLabel.attributedText = attributedText

No hay comentarios:

Publicar un comentario