cocoa – 如何在使用自动布局时使用动画折叠NSSplitView窗格?

cocoa – 如何在使用自动布局时使用动画折叠NSSplitView窗格?,第1张

概述我已经尝试了我能想到的一切,包括我在SO和其他邮件列表上找到的所有建议,但我无法弄清楚如何在启用自动布局时以编程方式折叠带有动画的NSSplitView窗格. 这就是我现在所拥有的(用Swift编写的乐趣),但它有多种方式: @IBAction func toggleSourceList(sender: AnyObject?) { let isOpen = !splitView.isSub 我已经尝试了我能想到的一切,包括我在SO和其他邮件列表上找到的所有建议,但我无法弄清楚如何在启用自动布局时以编程方式折叠带有动画的NssplitVIEw窗格.

这就是我现在所拥有的(用Swift编写的乐趣),但它有多种方式:

@IBAction func toggleSourceList(sender: AnyObject?) {    let isOpen = !splitVIEw.isSubvIEwCollapsed(sourceList.vIEw.supervIEw!)    let position = (isOpen ? 0 : self.lastWIDth)    if isOpen {        self.lastWIDth = sourceList.vIEw.frame.size.wIDth    }    NSAnimationContext.runAnimationGroup({ context in        context.allowsImplicitAnimation = true        context.timingFunction = camediatimingFunction(name: kcamediatimingFunctionEaseIn)        context.duration = self.duration        self.splitVIEw.setposition(position,ofdivIDerAtIndex: 0)    },completionHandler: { () -> VoID in    })}

期望的行为和外观是Mail.app,它的动画效果非常好.

我有一个完整的示例应用程序在https://github.com/mdiep/NSSplitViewTest可用.

解决方法 Objective-C的:

[[splitVIEwItem animator] setCollapse:YES]

迅速:

splitVIEwItem.animator().collapsed = true

来自Apple的帮助:

Whether or not the child VIEwController corresponding to the SplitVIEwItem is collapsed in the SplitVIEwController. The default is NO. This can be set with the animator proxy to animate the collapse or uncollapse. The exact animation used can be customized by setting it in the -animations dictionary with a key of “collapsed”. If this is set to YES before it is added to the SplitVIEwController,it will be initially collapsed and the SplitVIEwController will not cause the vIEw to be loaded until it is uncollapsed. This is KVC/KVO compliant and will be updated if the value changes from user interaction.

总结

以上是内存溢出为你收集整理的cocoa – 如何在使用自动布局时使用动画折叠NSSplitView窗格?全部内容,希望文章能够帮你解决cocoa – 如何在使用自动布局时使用动画折叠NSSplitView窗格?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1020745.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存