我有一个MAAttachedWindow
(的子类NSWindow
),它包含一个空白视图(contentView
)和一些任意子视图(现在是一个NSImageView
)。在加载时,我试图以动画方式将窗口垂直调整 100 像素。
此代码块初始化我的窗口和视图:
_popoverContentView = [[NSView alloc] initWithFrame: aFrame];
NSImageView *img = [[NSImageView alloc] initWithFrame: aFrame];
[img setImage: [NSImage imageName: "@my_debug_image"]];
[img setAutoresizingMask: NSViewHeighSizable];
[_popoverContentView setAutoresizesSubviews: YES];
[_popoverContentView addSubview: img];
popover = [[MAAttachedWindow alloc] initWithView: _popoverContentView attachedToPoint: aPoint inWindow: nil onSide: MAPositionBottom atDistance: aDist];
这个代码块负责动画:
NSRect newPopoverFrame = popover.frame;
NSRect newPopoverContentViewFrame = _popoverContentView.frame;
newPopoverFrame.size.height += 100;
newPopoverContentViewFrame.size.height += 100;
[_popoverContentView animator] setFrame: newPopoverContentViewFrame];
[[popover animator] setFrame: newPopoverFrame display: YES animate: YES];
现在这一切都(几乎)按预期工作,但是如本视频所示,动画不可靠、摇晃和跳跃。我似乎无法确定我的代码中是什么导致了这种情况,或者如何将图像视图锁定到位。