Create informational popup / tooltip in Cocoa

2019-04-04 18:16发布

The question title is kind of vague, but I really don't know what the thing is called.

I am trying to create one of those yellow informational popup things. Anyone can tell me what they're called and how I can create them?

2条回答
Juvenile、少年°
2楼-- · 2019-04-04 18:51

That's called a tool tip. You can set the tool tip for any NSView using setToolTip:.

查看更多
家丑人穷心不美
3楼-- · 2019-04-04 18:57

If you are using NSTextView, you can even set an attribute for a certain range in NSTextstorage, that displays the Tooltip. Something like:

[textStorage addAttribute:NSToolTipAttributeName
                    value:error.description
                    range:range];
查看更多
登录 后发表回答