所有的,
NSMutableDictionary* constattrs = [NSMutableDictionary dictionaryWithCapacity:5];
[attrs setObject:[NSNumber numberWithInt:( NSUnderlinePatternDot )] forKey:NSUnderlineStyleAttributeName];
[attrs setValue:style.GetUnderlineColour() forKey:NSUnderlineColorAttributeName];
[m_textView setTypingAttributes:attrs];
上面的代码编译良好并执行,但视图中的文本不会变为下划线。
我在OSX 10.13下测试,最低要求是10.9。
我错过了什么?
蒂亚!
[编辑]:
NSRange range = NSMakeRange(start, end-start);
NSTextStorage* storage = [m_textView textStorage];
if( style.HasFontUnderlined() )
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:[NSNumber numberWithInt:( NSUnderlinePatternDot )] forKey:NSUnderlineStyleAttributeName];
[dict setValue:style.GetUnderlineColour() forKey:NSUnderlineColorAttributeName];
[storage addAtributes:dict range:range];
[dict release];
我收到上面代码的编译警告:
warning: instance method '-addAtributes:range:' not found (return type defaults to 'id'); did you mean '-addAttributes:range:'? [-Wobjc-method-access]
你能帮忙吗?
[/编辑]