2013-02-26 3 views
-1

J'ai un TextView dans lequel j'ai besoin de texte pour changer les couleurs et les polices. Toute méthode est disponible autre que le texte principal. S'il vous plaît aider.Ajout de couleur au texte dans TextView

+0

voulez-vous modifier un texte de tout le texte, non? – Dilip

+0

Vous devriez facilement trouver des réponses à votre problème en effectuant une recherche sur Internet. – bdesham

Répondre

3

J'ai besoin de texte pour changer les couleurs et les polices.

Vous cherchez certainement pour NSAttributedString


De Source

NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Hello. That is a test attributed string."]; 
[str addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(3,5)]; 
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(10,7)]; 
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:20.0] range:NSMakeRange(20, 10)]; 
label.attributedText = str; 
+0

Bon code .. seulement changer le ** label ** à ** textView ** :) – pbibergal

+0

Merci Anoop Vaidya – Deepak

+0

@Bing: se sentir heureux d'accepter et upvote :) –

Questions connexes