2013-05-11 20 views
2

IOS 6.x中有拼寫正確的單詞嗎?IOS 6.x中的正交斷字詞

事情是這樣的:

NSStiring *string = @"In June 2010 at the World Wide Developers Conference, Apple announced version 4 of Xcode during the Developer Tools State of the Union address."; 
UILabel *label = [[UILabel alloc] init]; 
    label.text = string; 

如果框架的UILabel會窄,得到下一個:

在2010年6月在
萬維網
開發商CON-
擾, Apple
已發佈ver-
Xcode的第4個
期間Devel-
oper工具狀態
聯盟ad-
着裝。

回答

11

使用的NSAttributedString與NSParagraphStyle與1

+1

非常感謝!它按我的意願工作。 – Dickordia 2013-05-11 23:35:13

0

一個hyphenationFactor這將幫助你。請更改的UILabel文本平原歸因我試過的Xcode 7+ enter image description here

1

雨燕3.0

let paragraphStyle = NSMutableParagraphStyle() 
paragraphStyle.hyphenationFactor = 1.0 
let attributedString = NSMutableAttributedString(string: 「Your String」, attributes: [NSParagraphStyleAttributeName:paragraphStyle]) 
self.yourLabel.attributedText = attributedString