我正在尝试使用删除线创建一个属性字符串,但是,这个简单的任务似乎比我预期的更难理解.这是我目前的(不起作用).谢谢您的帮助!
NSAttributedString *theTitle = [[[NSAttributedString alloc] initWithString:@"strikethrough text" attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSColor whiteColor], NSForegroundColorAttributeName, NSUnderlinePatternSolid, NSStrikethroughStyleAttributeName, nil]] autorelease];
因此,我试图获得与NSTextView中特定字符的位置相对应的NSPoint或NSRect.这就是我到目前为止所做的(效果不佳,结果似乎有些不可预测.
NSRange theTextRange = [[theTextView layoutManager] glyphRangeForCharacterRange:[theTextStorage editedRange] actualCharacterRange:NULL];
NSRect theTextRect = [[theTextView layoutManager] boundingRectForGlyphRange:theTextRange inTextContainer:[theTextView textContainer]];