【问题标题】:Repositioned standardWindowButton moves back to the top重新定位的标准窗口按钮移回顶部
【发布时间】:2015-10-06 11:47:36
【问题描述】:

我正在重新定位 NSWindow 标准按钮,如下所示:

NSButton *closeButton = [self standardWindowButton:NSWindowCloseButton]; [closeButton setFrameOrigin: NSMakePoint(50,20)];

这可以完美地工作,直到在窗口上出现一个模式表,此时按钮会跳到左上角(通常在哪里)。我想把它放在标题栏的中心(使用NSTitlebarAccessoryViewController增加了高度。

这只是在 El Capitan 之后才开始发生,我无法让它自动重新定位回中心。我试过观察窗口事件并强制重新布局,但它会在一段时间后重置。有什么方法可以重新定位这些按钮并使它们“粘”起来?

【问题讨论】:

    标签: macos cocoa osx-elcapitan appkit nstitlebaraccessoryviewcontroller


    【解决方案1】:

    最终观察每个按钮上的NSViewDidUpdateTrackingAreasNotification,然后再次重新定位它们。操作系统似乎一直在无故更新位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-02
      • 2012-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多