小编amb*_*rse的帖子

带有删除线的NSAttributedString

我正在尝试使用删除线创建一个属性字符串,但是,这个简单的任务似乎比我预期的更难理解.这是我目前的(不起作用).谢谢您的帮助!

NSAttributedString *theTitle = [[[NSAttributedString alloc] initWithString:@"strikethrough text" attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSColor whiteColor], NSForegroundColorAttributeName, NSUnderlinePatternSolid, NSStrikethroughStyleAttributeName, nil]] autorelease];
Run Code Online (Sandbox Code Playgroud)

cocoa

15
推荐指数
2
解决办法
1万
查看次数

来自NSTextView中的字符的NSPoint/NSRect

因此,我试图获得与NSTextView中特定字符的位置相对应的NSPoint或NSRect.这就是我到目前为止所做的(效果不佳,结果似乎有些不可预测.

NSRange theTextRange = [[theTextView layoutManager] glyphRangeForCharacterRange:[theTextStorage editedRange] actualCharacterRange:NULL];
NSRect theTextRect = [[theTextView layoutManager] boundingRectForGlyphRange:theTextRange inTextContainer:[theTextView textContainer]];
Run Code Online (Sandbox Code Playgroud)

cocoa nstextview

3
推荐指数
1
解决办法
1385
查看次数

标签 统计

cocoa ×2

nstextview ×1