Ios UIView动画不工作
我正在使用动画来更改fadein和fadeout的视图框架。但是它们不起作用。 操作系统:ios7 试试这个:Ios UIView动画不工作,ios,objective-c,uiview,ios7,uiviewanimation,Ios,Objective C,Uiview,Ios7,Uiviewanimation,我正在使用动画来更改fadein和fadeout的视图框架。但是它们不起作用。 操作系统:ios7 试试这个: objArticleTable.alpha = 0.0f; objArticleTable.hidden = NO; [UIView animateWithDuration:0.5f animations:^{ objArticleTable.alpha = 1.0; } completion:^(BOOL finished) {
objArticleTable.alpha = 0.0f;
objArticleTable.hidden = NO;
[UIView animateWithDuration:0.5f
animations:^{
objArticleTable.alpha = 1.0;
} completion:^(BOOL finished) {
//Done
}];
对于
淡入
效果,您可以使用
objArticleTable.alpha = 0.0f;
[UIView animateWithDuration:0.8 animations:^{
[objArticleTable setFrame:CGRectMake(CGRectGetMinX([objArticleTable frame]), CGRectGetMinY([objArticleTable frame]), CGRectGetWidth([objArticleTable frame]), 50)];}];
objArticleTable.alpha = 1.0f;
}
completion:nil];
对于淡出
objArticleTable.alpha = 1.0f;
[UIView animateWithDuration:0.8 animations:^{
[objArticleTable setFrame:CGRectMake(CGRectGetMinX([objArticleTable frame]), CGRectGetMinY([objArticleTable frame]), CGRectGetWidth([objArticleTable frame]), 0)];}];
objArticleTable.alpha = 0.0f;
}
completion:nil];
试试这个。。仅当您要更改alpha将采用的fadein和fadeout的帧时,才使用“设置帧”
[UIView animateWithDuration:10.0f animations:^{
objArticleTable.alpha = 1.0f;
[objArticleTable setFrame:CGRectMake(CGRectGetMinX([objArticleTable frame]),CGRectGetMinY([objArticleTable frame]), CGRectGetWidth([objArticleTable frame]), 50)];
}
completion:^(BOOL finished){
[UIView animateWithDuration:10.0f animations:^{
objArticleTable.alpha = 0.0f;
[objArticleTable setFrame:CGRectMake(CGRectGetMinX([objArticleTable frame]), CGRectGetMinY([objArticleTable frame]), CGRectGetWidth([objArticleTable frame]), 0)];
}];
}];
是否将框架的高度设置为0???为什么?我已经把它从50改成0了,你可以修改<代码> Alpha < /代码>来制作<代码> FAUDOUT 和<代码> FADEIN < /代码>……你在主线程上执行动画吗?考虑使用仿射变换来执行操作。
[UIView animateWithDuration:10.0f animations:^{
objArticleTable.alpha = 1.0f;
[objArticleTable setFrame:CGRectMake(CGRectGetMinX([objArticleTable frame]),CGRectGetMinY([objArticleTable frame]), CGRectGetWidth([objArticleTable frame]), 50)];
}
completion:^(BOOL finished){
[UIView animateWithDuration:10.0f animations:^{
objArticleTable.alpha = 0.0f;
[objArticleTable setFrame:CGRectMake(CGRectGetMinX([objArticleTable frame]), CGRectGetMinY([objArticleTable frame]), CGRectGetWidth([objArticleTable frame]), 0)];
}];
}];