menuitem视图的动画显示为flash

时间:2017-03-09 03:02:01

标签: objective-c macos core-animation nswindow nsanimation

flash animation 我将CalendarViewController的视图设置为menuitem.view,当触摸menuitem.view的底部时,menuitem.view将开始动画,但我发现动画显示为闪烁。我能做些什么才能使动画变得更加流畅。

- (IBAction)respondToTapBottomView:(NSButton *)sender {
NSSize size = self.view.frame.size;
NSLog(@"%@", NSStringFromRect(self.view.window.frame));
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
    context.duration = 0.5;
    CGFloat height = 10;
    if (self.bottomContentHeightConstraint.constant >= 30) {
        height = 10;
    } else {
        height = 97;
    }
    CGFloat windowHeight = self.calendarView.frame.size.height + height;
    self.view.animator.frame = CGRectMake(0, 0, size.width, windowHeight);
    self.bottomContentHeightConstraint.animator.constant = height;
} completionHandler:^{
    NSLog(@"%@", NSStringFromRect(self.view.window.frame));
}];

}

1 个答案:

答案 0 :(得分:0)

我放弃了使用这种方法,最后,我通过绘制自定义popoverView而不是使用menuItem.view解决问题。