【发布时间】:2018-04-03 19:56:30
【问题描述】:
在我的应用程序中,我正在尝试构建一个动画,在收到通知时调整 UIViewController 的大小。
我创建了一个容器UIViewController 来封装孩子。然后我写了下面的代码来调整孩子UIViewController的大小。
[UIView animateKeyframesWithDuration:0.5
delay:0
options:0
animations:^{
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5 animations:^{
for(int i = 0; i < [self.viewControllers count]; i++) {
UIViewController *vc = [self.viewControllers objectAtIndex:i];
vc.view.frame = CGRectMake(0, [self topOffset], self.view.frame.size.width, self.view.frame.size.height-[self topOffset]);
}
}];
} completion:^(BOOL finished) {
}];
但是,现在发生的情况是立即执行高度更改并且 y 更改是动画的,使得视图看起来像是在向下滑动。关于我可以改变什么以使其调整大小的任何想法?
【问题讨论】:
-
不要为
frame设置动画,而是尝试同时为bounds和center设置动画,看看是否会有所不同。
标签: ios objective-c uiviewcontroller uikit