Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这听起来很基本,但话又说回来可能不是。我在一个单元格中有一些文本,我想在一个事件发生时加粗,在另一个事件发生时取消加粗,我知道如何处理该事件,但是如何将其变为粗体然后取消加粗。
使文本粗体是特定范围:
NSMutableAttributedString *theText = [theTextView textStorage]; [theText applyFontTraits:NSBoldFontMask range:NSMakeRange(0,[text length])];
(可选)如何获取所选范围:
NSRange theSelectedRange = [theTextView selectedRange];