我是初学者。我正在更新视图的框架。我对动画有点困惑。我只是想知道如何使用任何类型的动画更新视图的框架。
这是我更新框架的地方:
- (IBAction)btnCountries:(id)sender {
_dropDownView.hidden = NO;
fromCountry=YES;
fromCity = NO;
fromState = NO;
_dropDownView.frame = CGRectMake(132.0f, 63.0f, 172.0f, 308.0f);
[self.tblDropDown reloadData];
}
非常感谢任何帮助。
答案 0 :(得分:0)
您可以使用UIView方法animationWithDuration: 或CoreAnimation框架。
[UIView animateWithDuration:0.5 animations:^{
// animation here
_dropDownView.frame = CGRectMake(132.0f, 63.0f, 172.0f, 308.0f);
}];
答案 1 :(得分:0)
[self.view setUserInteractionEnabled:NO];
[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionTransitionNone
animations:^{
_dropDownView.frame = CGRectMake(132.0f, 63.0f, 172.0f, 308.0f);
}
completion:^(BOOL finished) {
[self.view setUserInteractionEnabled:YES];
}];
答案 2 :(得分:0)
UIView支持动画如下,
_dropDownView.hidden = NO;fromCountry=YES;
fromCity = NO;
fromState = NO;
UIView animateWithDuration:1.0f animations:^
{
_dropDownView.frame = CGRectMake(132.0f, 63.0f, 172.0f, 308.0f);
} completion:^(BOOL finished)
{
[self.tblDropDown reloadData];
}
答案 3 :(得分:0)
尝试以下代码
- (IBAction)btnCountries:(id)sender {
_dropDownView.hidden = NO;
fromCountry=YES;
fromCity = NO;
fromState = NO;
[UIView animateWithDuration:2.0
animations:^{
CGRect frame = _dropDownView.frame;
frame=CGRectMake(132.0f, 63.0f, 172.0f, 308.0f);
_dropDownView.frame = frame;
}
completion:^(BOOL finished){
[self.tblDropDown reloadData];
}];
}
希望它可以帮助你..