2010-04-25 54 views

回答

2

Yes和No,

的NSString是一個簡單的類,即只存儲未格式化的文本,但您可以使用NSAttributedString存儲這樣的信息,即

NSAttributedString* italicText = [[NSAttributedString alloc] initWithString:myNsString attributes:myCrossOutAttributes]; 
+0

注意:自從≥3.2以來,NSAttributedString纔可用。 – kennytm 2010-04-25 15:58:48

+0

拍攝...如果我開發3.0,我不能出擊? – ncohen 2010-04-25 16:07:52

+1

不,不使用NSAttributedString。然而,你可以繼承UILabel並在-drawRect中添加一些自定義繪圖代碼,就像KennyTM所說的那樣。 – Rengers 2010-04-25 16:37:28

3
NSMutableAttributedString *strikeThroughString = [[NSMutableAttributedString alloc] initWithString:anyString]; 
[strikeThroughString addAttribute:NSStrikethroughStyleAttributeName value:(NSNumber *)kCFBooleanTrue range:NSMakeRange(0, [as length])]; 
[m_cObjTaskTitle setAttributedText:strikeThroughString =]; 
cObjTaskTitle = UILabel ;