UIView动画无效

时间:2014-03-10 10:00:09

标签: ios objective-c uiview ios7 uiviewanimation

我正在使用动画来改变fadein和fadeout的视图。但是它们不起作用。 OS:ios7

[UIView animateWithDuration:0.8 animations:^{
      [objArticleTable setFrame:CGRectMake(CGRectGetMinX([objArticleTable frame]), CGRectGetMinY([objArticleTable frame]), CGRectGetWidth([objArticleTable frame]), 0)];}];

3 个答案:

答案 0 :(得分:1)

试试这个:


objArticleTable.alpha = 0.0f;
objArticleTable.hidden = NO;
[UIView animateWithDuration:0.5f
     animations:^{
         objArticleTable.alpha = 1.0;
     } completion:^(BOOL finished) {
          //Done
     }];

答案 1 :(得分:0)

对于fade-in效果,您可以使用

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

适用于fade-out

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

答案 2 :(得分:0)

尝试此操作..仅当您想要更改alpha将采用fadein和fadeout的帧时才使用set frame ..

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