Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIView动画不工作_Ios_Objective C_Uiview_Ios7_Uiviewanimation - Fatal编程技术网

Ios UIView动画不工作

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) {

我正在使用动画来更改fadein和fadeout的视图框架。但是它们不起作用。 操作系统:ios7

试试这个:


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)];
}];
}];