J'essaie de mettre un text justifié pour un UITextView
avec NSMutableAtsortingbutedSsortingng
, le NSMutableAtsortingbutedSsortingng
est composé de différents NSAtsortingbutedSsortingng
parce que j'ai besoin de police gras et régulière, donc j'ajoute NSSsortingng
différent, c'est mon NSMutableAtsortingbutedSsortingng
:
NSAtsortingbutedSsortingng *one = [[NSAtsortingbutedSsortingng alloc] initWithSsortingng:@"abc" atsortingbutes:boldDict]; NSAtsortingbutedSsortingng *two = [[NSAtsortingbutedSsortingng alloc] initWithSsortingng:@" def" atsortingbutes:regularDict]; NSAtsortingbutedSsortingng *three = [[NSAtsortingbutedSsortingng alloc] initWithSsortingng:@" ghi" atsortingbutes:boldDict]; NSMutableAtsortingbutedSsortingng *ssortingng = [[NSMutableAtsortingbutedSsortingng alloc] initWithAtsortingbutedSsortingng:one]; [ssortingng appendAtsortingbutedSsortingng:two]; [ssortingng appendAtsortingbutedSsortingng:three];
J'ai essayé ceci:
[self.text_view setTextAlignment:NSTextAlignmentJustified]
et ça:
NSMutableParagraphStyle *paragraphStyles = [[NSMutableParagraphStyle alloc] init]; paragraphStyles.alignment = NSTextAlignmentJustified; Dictionary *atsortingbutes = @{NSParagraphStyleAtsortingbuteName: paragraphStyles};
et appliquez cela à NSMutableAtsortingbutedSsortingng, mais aucun ne fonctionne. comment je peux faire?
J'ai corrigé le même problème en spécifiant la couleur d'arrière-plan transparente pour le NSAtsortingbutedSsortingng.
Ressemble à un bogue dans le code UILabel qui devrait rendre NSAtsortingbutedSsortingng simple comme NSSsortingng.
Exemple de Xamarin.iOS:
var paragraphStyle = new NSMutableParagraphStyle(); paragraphStyle.Alignment = UITextAlignment.Justified; var atsortingbutedText = new NSAtsortingbutedSsortingng(simpleSsortingng, paragraphStyle: paragraphStyle, backgroundColor: Color.Transparent.ToUIColor()); myLabel.AtsortingbutedText = atsortingbutedText;