如何使用动画更改视图的框架?
How to change the frame of a view with animations?
我是初学者。我正在更新视图的框架。我对动画有点困惑。我只想知道如何使用任何类型的动画更新视图的框架。
这是我更新框架的地方:
- (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];
}
非常感谢任何帮助。
您可以使用 UIView 方法 animationWithDuration:
或 CoreAnimation 框架。
[UIView animateWithDuration:0.5 animations:^{
// animation here
_dropDownView.frame = CGRectMake(132.0f, 63.0f, 172.0f, 308.0f);
}];
[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];
}];
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];
}
试试下面的代码
- (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];
}];
}
希望对你有帮助..
我是初学者。我正在更新视图的框架。我对动画有点困惑。我只想知道如何使用任何类型的动画更新视图的框架。
这是我更新框架的地方:
- (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];
}
非常感谢任何帮助。
您可以使用 UIView 方法 animationWithDuration: 或 CoreAnimation 框架。
[UIView animateWithDuration:0.5 animations:^{
// animation here
_dropDownView.frame = CGRectMake(132.0f, 63.0f, 172.0f, 308.0f);
}];
[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];
}];
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];
}
试试下面的代码
- (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];
}];
}
希望对你有帮助..