NSTextField's attributed string is delayed in rendering

怎甘沉沦 提交于 2019-12-05 06:19:36

I ran into this same problem. The solution I found was to explicitly set the NSFontAttributeName on the attributed string. I created an NSFont object that matched the font I had set in IB for my textfield and set that attribute like so:

NSFont *font = [NSFont fontWithName:@"Lucida Grande" size:(CGFloat)13.0];
[attrString addAttribute:NSFontAttributeName value:font range:range];

As far as I know that's just normal AppKit weirdness.

I've had success using this custom class to render text fields as links, you just add it in interface builder and set its attributed string value like normal:

DSClickableURLTextField

You also have the option of using an NSButton, though that's more of a pain, and you don't get the hand cursor without extra work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!