J'essaie d'afficher une chaîne attributeString dans un UILabel et j'ai ajouté la propriété "firstLineHeadIndent" à ses attributs.assignedString utilisant l'attribut "firstLineHeadIndent" ne s'affiche pas correctement dans un UILabel
Avec 16 caractères de "国", il devrait se casser en deux lignes. Mais UILabel vient de me montrer 14 caractères en une seule ligne comme le montre l'image "pas correct avec 16 caractères".
Et il peut montrer correctement lors de l'utilisation de 17 caractères.Peut-on me dire pourquoi? Voici mon code:
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 300, 80)];
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;
[self.view addSubview: label];
NSMutableParagraphStyle *paraStyle = [NSMutableParagraphStyle new];
paraStyle.firstLineHeadIndent = 40;
paraStyle.lineBreakMode = NSLineBreakByWordWrapping;
NSDictionary *attrs = @{
NSParagraphStyleAttributeName:paraStyle,
NSFontAttributeName:[UIFont systemFontOfSize:17 weight:UIFontWeightBold],
NSKernAttributeName:@.9f
};
label.attributedText = [[NSAttributedString alloc] initWithString:@"国国国国国国国国国国国国国国国国" attributes:attrs];}
Non correct avec 16 caractères:
Afficher correctement avec 17 caractères:
u ur problème résolu –