我创建的字符串取决于用户输入文本字段的内容:
NSString *book = [[NSString alloc] initWithFormat:@"%@%@", bookTitle.text, afterbook];
然后这个字符串是更大字符串的一部分:
NSString *msg = [[NSString alloc] initWithFormat:@"%@%@%@%@%@%@%@%@%@%@%@%@%@%@", lastname,
firstname, secondfirstname, secondlastname, thirdfirstname, thirdlastname, book, numb, volume, pubcity, pubcomp, year, pages, print];
我想格式化NSString *书,使其成为斜体。我不关心在视图上显示它,但我确实希望能够将其复制到剪贴板,以便我可以将其粘贴到iPad上的Pages等程序中。
答案 0 :(得分:4)
NSStrings是纯文本。它们没有样式,字体,颜色或任何其他只在绘制字符串时才变得相关的概念。
您需要使用UIKit以您希望的方式绘制每个子字符串,或者创建NSAttributedString,使用相应范围的Core Text string attributes来应用斜体,并使用{{3}绘制整个属性字符串。
答案 1 :(得分:0)
您无法将NSString
格式化为斜体。