Create informational popup / tooltip in Cocoa

前提是你 提交于 2019-12-05 14:40:30

问题


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?


回答1:


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




回答2:


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];


来源:https://stackoverflow.com/questions/6082311/create-informational-popup-tooltip-in-cocoa

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