7
A
回答
7
myLabel.textAlignment = UITextAlignmentRight;
iOS Developer Library是一个很好的资源。
1
它可以通过接口生成器。 或label.textAlignment = UITextAlignmentRight;
3
以上方法已被弃用。新的方法调用:
label.textAlignment = NSTextAlignmentRight;
3
你应该设置文本对齐方式对齐并设置属性串基地书写方向从右至左:
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
2
这里是: 要小心,如果充分证明需要应用,firstLineIndent
不应该为零。
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];
相关问题
- 1. 如何对齐的UILabel文本框
- 2. 右对齐文本?
- 3. 对齐文本右
- 4. 右对齐文本
- 5. UILabel中对齐文本iOS
- 6. UILabel段落文本对齐
- 7. 对齐两个UILabel文本
- 8. 右对齐的UILabel对象文本稍微偏离
- 9. Android如何对齐文本左右editText
- 10. 如何对齐文本到右侧
- 11. 对齐文本右对齐图标
- 12. 对齐文本的div右
- 13. Listpicker文本对齐向右
- 14. TextField右对齐文本
- 15. 右对齐印刷文本
- 16. NSString左右对齐文本?
- 17. 对齐文本右表
- 18. 对齐文本右asp:changepassword
- 19. TableLayout,文本 - 右对齐
- 20. 如何在一段右对齐的文本下对齐元素?
- 21. 的UILabel视图不对齐到右
- 22. 右对齐文本框内的文本
- 23. 自定义UILabel文本对齐
- 24. 垂直对齐UILabel中的文本
- 25. 将UILabel文本对齐到左下角
- 26. 如何对齐右对齐的列
- 27. 右对齐文件
- 28. UILabel对齐
- 29. 如何使用UILabel和NSAttributedString垂直对齐文本
- 30. 如何创建文本,右对齐文件类型的输入?
自iOS6以来,UITextAlignmentRight已被弃用。改用NSTextAlignmentRight。 – jbandi
“UITextAlignmentRight”或“NSTextAlignmentRight”只能对齐文本,但文本不正确请参阅@Hashem Aboonajmi或@Aryan回答 –