我正在尝试为我的uitoolbar制作动画。我正在努力扩展和收缩我的uiview。我希望工具栏与视图一起动画。但是这里uitoolbar首先扩展和收缩然后uiview是动画。所以uitoolbar框架正在根据rect进行更改但不是动画。有人可以告诉我如何动画uitoolbar。除了工具栏,我还想为tabbar设置动画。我应该怎么做呢。
在我看来,我写了以下代码:
[UIView animateWithDuration:1.0 animations:^(void){
[recordDetailView setFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, recordDetailView.frame.size.height)];
[normalModeToolbar setFrame:CGRectMake(0.0, 0.0,self.view.frame.size.width, 49)];
[self.view bringSubviewToFront:recordDetailView];
} completion:^(BOOL finished){
}
];
答案 0 :(得分:1)
UIViewAnimationOptionLayoutSubviews (iOS> 4.0)应该在没有动画大小更改时解决问题。
[UIView animateWithDuration:1.0
delay:0
options:UIViewAnimationOptionLayoutSubviews
animations:^{
[recordDetailView setFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, recordDetailView.frame.size.height)];
[normalModeToolbar setFrame:CGRectMake(0.0, 0.0,self.view.frame.size.width, 49)];
}
completion:nil
];
答案 1 :(得分:0)
您是否尝试过使用边界?
[UIView animateWithDuration:1.0 animations:^(void){
yourView.bounds = CGRectMake(yourView.bounds.origin.x,
yourView.bounds.origin.y,
yourView.bounds.size.width * 2, // target width
yourView.bounds.size.height);
}];
此外,我还会尝试在启动动画之前将recordDetailView
置于前面。