¿Cómo justificar a la derecha el texto de UILabel?¿Cómo justificar a la derecha el texto de UILabel?
gracias
¿Cómo justificar a la derecha el texto de UILabel?¿Cómo justificar a la derecha el texto de UILabel?
gracias
myLabel.textAlignment = UITextAlignmentRight;
iOS Developer Library es un buen recurso.
puede ser a través del constructor de interfaz. o label.textAlignment = UITextAlignmentRight;
Los métodos anteriores han quedado en desuso. La nueva llamada al método es:
label.textAlignment = NSTextAlignmentRight;
Se debe ajustar la alineación del texto a la dirección de escritura justificada y conjunto base una cadena con atributos a RightToLeft:
var label: UILabel = ...
var text: NSMutableAttributedString = ...
var paragraphStyle: NSMutableParagraphStyle = NSParagraphStyle.defaultParagraphStyle().mutableCopy() as! NSMutableParagraphStyle
paragraphStyle.alignment = NSTextAlignment.Justified
paragraphStyle.lineBreakMode = NSLineBreakMode.ByWordWrapping
paragraphStyle.baseWritingDirection = NSWritingDirection.RightToLeft
text.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, text.length))
label.attributedText = text
aquí es: tener cuidado si completa justificar las necesidades que deben aplicarse , firstLineIndent
no debe ser cero.
NSMutableParagraphStyle* paragraph = [[NSMutableParagraphStyle alloc] init];
paragraph.alignment = NSTextAlignmentJustified;
paragraph.baseWritingDirection = NSWritingDirectionRightToLeft;
paragraph.firstLineHeadIndent = 1.0;
NSDictionary* attributes = @{
NSForegroundColorAttributeName: [UIColor colorWithRed:0.2 green:0.239 blue:0.451 alpha:1],NSParagraphStyleAttributeName: paragraph};
NSString* txt = @"your long text";
NSAttributedString* aString = [[NSAttributedString alloc] initWithString: txt attributes: attributes];
UITextAlignmentRight está en desuso desde iOS6. Use NSTextAlignmentRight en su lugar. – jbandi
'UITextAlignmentRight' o' NSTextAlignmentRight' solo alinean a la derecha el texto, pero el texto no está justificado, vea @Hashem Aboonajmi o @Aryan answers –