iPhone - Strike out an NSString [duplicate]

独自空忆成欢 提交于 2019-12-08 04:02:01

问题


I would like to know if there is an easy way to strike/cross out some text on the iPhone?

Thanks


回答1:


Yes and No,

NSString is a simple class, that only stores unformated text, but you can use an NSAttributedString to store such information, i.e.

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



回答2:


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


来源:https://stackoverflow.com/questions/2708732/iphone-strike-out-an-nsstring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!