J'ai une chaîne comme ce qui suit:Comment mettre en gras plusieurs instances d'un caractère dans un NSString?
NSString *a = @"* This is a text String \n * Followed by another text String \n * Followed by a third"
je dois l'imprimer en trois lignes. Maintenant, je voulais que les points d'Astérix soient en caractères gras. J'ai donc essayé:
NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:a];
[att addAddtribute:NSFontAttributeName value:SOMEBOLDFONT range:[a rangeOfString:@"*"]];
Mais cela ne fait que doubler les deuxième et troisième astérix. Comment puis-je les obtenir tous en gras?
Il semble y avoir seulement deux astérisques dans la chaîne, typo? – sooper
Oui. Mes excuses. –
Ce code ne va pas compiler. Je recommande vraiment que vous postez le code que vous demandez. – gnasher729