簡體   English   中英

UILabel段文字對齊

[英]UILabel paragraph text alignment

我正在研究Iphone應用程序,我需要顯示一個大文本。 我需要它有一個段落對齊。 請參考下面的圖片進行說明。

我試圖使用UILabel和UITextView但無法找到屬性來執行此操作。

在此輸入圖像描述

對於ios> 7.1,只需將textAligment屬性設置為NSTextAlignmentJustified,而不使用任何第三方庫:

UILabel *label = [UILabel alloc] init];
label.textAligment = NSTextAlignmentJustified;

UITextView和UILabel他們不提供這樣的對齊。 您可以改用UIWebview。

你可以使用<p style="text-align:justify">Your text goes here.</p>

這可能會有所幫助。

使用具有UITextAlignmentJustify的TTTAttributedLabel NSAtributedString標簽

 yourTTTAttributedLabel.textAlignment = UITextAlignmentJustify; 

另一種替代方法是使用具有UITextAlignmentJustify的OHAttributedLabel NSAtributedString標簽

 yourOHAttributedLabel.textAlignment = UITextAlignmentJustify; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM