Objective c 设置动画-高度到底部而不是顶部
我想将imageview的高度降低到0。我用这段代码试过了。 我的代码正在运行,但是imageview会降低从底部到顶部的高度,但是我希望动画是从顶部到底部的 有没有达到这个目的的功能?还有一个解决方案是在动画结束时轻微反弹吗Objective c 设置动画-高度到底部而不是顶部,objective-c,animation,Objective C,Animation,我想将imageview的高度降低到0。我用这段代码试过了。 我的代码正在运行,但是imageview会降低从底部到顶部的高度,但是我希望动画是从顶部到底部的 有没有达到这个目的的功能?还有一个解决方案是在动画结束时轻微反弹吗 [UIView animateWithDuration:1.5 animations:^{ _Image.frame = CGRectMake(5, 120, 35, 0); }]; 试试看: _Image.frame = CGRectMake(5, 120,
[UIView animateWithDuration:1.5 animations:^{
_Image.frame = CGRectMake(5, 120, 35, 0);
}];
试试看:
_Image.frame = CGRectMake(5, 120, 35, 0);
[UIView animateWithDuration:1.5 animations:^{
[self.view layoutIfNeeded];
// OR
[_Image layoutIfNeeded];
}];
试试看:
_Image.frame = CGRectMake(5, 120, 35, 0);
[UIView animateWithDuration:1.5 animations:^{
[self.view layoutIfNeeded];
// OR
[_Image layoutIfNeeded];
}];
您应该将
\u Image.frame.origin.y
与\u Image.frame.size.height
一起设置动画:
CGFloat initialImageHeight = _Image.frame.size.height;
[UIView animateWithDuration:1.5 animations:^{
_Image.frame = CGRectMake(5, 120 - initialImageHeight, 35, 0);
}];
您应该将
\u Image.frame.origin.y
与\u Image.frame.size.height
一起设置动画:
CGFloat initialImageHeight = _Image.frame.size.height;
[UIView animateWithDuration:1.5 animations:^{
_Image.frame = CGRectMake(5, 120 - initialImageHeight, 35, 0);
}];