gpt4 book ai didi

macos - NSWindow 调整大小后 NSView 变形

转载 作者:行者123 更新时间:2023-11-28 09:12:56 25 4
gpt4 key购买 nike

我正在使用 animator() 在我的应用程序的帧( subview )之间横向滚动 NSScrollView。当动画发生并且我调整 NSWindow 的大小时,整个 NSView 会像这样扭曲:

NSView gets distorted during NSWindow resize

这是负责转换的代码:

func goToFrame(frameNumber: Int) {
dispatch_async(dispatch_get_main_queue(), {
var clipView: NSClipView = self.container.contentView
newOrigin: NSPoint = clipView.bounds.origin
newOrigin.x = CGFloat(self.viewWidth * frameNumber)

NSAnimationContext.beginGrouping()
NSAnimationContext.currentContext().duration = 0.4
self.container.contentView.animator().bounds.origin = newOrigin
self.container.reflectScrolledClipView(self.container.contentView)
NSAnimationContext.endGrouping()
})
}

知道它为什么会那样做吗?我没有在日志中收到任何警告。

最佳答案

Ken Thomases 在评论中回答:

这一行:

self.container.contentView.animator().bounds.origin = newOrigin

应该改为:

self.container.contentView.animator().setBoundsOrigin(newOrigin)

关于macos - NSWindow 调整大小后 NSView 变形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28569594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com