在 Cocoa 中向窗口标题栏添加辅助文本?
我希望发布带有试用期的软件,我想知道如何在标题栏的右侧显示一个链接,告诉他们试用将持续多长时间,类似于:
。
有人有什么建议吗?
I was hoping to release my software with a trial period and I was wondering how I could show a link in the right side of my title bar telling them how long their trial will last similar to this:
.
Anyone have any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以获取 Windows 内容视图的超级视图并向其添加自定义视图。只要确保您的视图位置正确即可。下面是一些示例代码:
这里
otherView
是您想要放入标题栏中的视图。如果有工具栏按钮,此代码将不起作用 - 它们会重叠。幸运的是,有一个 API 可以获取工具栏按钮,以便您可以计算位置:您还必须确保设置视图的自动调整大小蒙版,使其保持在窗口的右上角:
You can get the superview of the windows content view and add a custom view to that. Just make sure you position your view correctly. Here is some sample code:
Here
otherView
is the view you want to put in your title bar. This code won’t work though if there is a toolbar button - they would overlap. Luckily there is an API to get the toolbar button so you can calculate the position:You also have to make sure that the autosizing masks for your view are set up so that it stays in the upper right corner of the window: