首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iPod Touch iOS 5动画卡顿

iPod Touch iOS 5动画卡顿
EN

Stack Overflow用户
提问于 2013-05-09 03:13:44
回答 1查看 201关注 0票数 0

我有一个在我的应用程序中充当徽章的UIView,当按下一个按钮时,徽章应该闪烁存在,然后做一个很好的挤压和拉伸动画。该动画在iPhone 4、iPhone 4s和iPhone 5上运行良好,但8 8GB的iPod touch (第四代) iOS 5.1.1有非常糟糕的卡顿效果。

popWithDuration:方法会导致卡顿,而resetCount方法会导致视图大小爆炸。不知道是否有人知道任何修复或变通方法。

下面是相关的方法,这个类是UIView的子类。

代码语言:javascript
复制
- (void)popWithDuration:(CGFloat)duration
{
    if(self.canAnimateLikedNumber)
    {
        if(self.waitingToReset){
            [self resetCount];
            return;
        }
        else
            self.canAnimateLikedNumber = FALSE;

        CGAffineTransform stretchTransform = CGAffineTransformMakeScale(1.5,1.5);
        CGAffineTransform squashTransform = CGAffineTransformMakeScale(1.0,1.0);

        [UIView animateWithDuration:duration delay:0.0f options:UIViewAnimationOptionLayoutSubviews animations:^{
            [self setAlpha:1.0f];
            [self setTransform:stretchTransform];
        } completion:^(BOOL finished) {
            [UIView  animateWithDuration:0.2f delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState animations:^{
                [self setTransform:squashTransform];
            } completion:^(BOOL finished) {
                self.canAnimateLikedNumber = TRUE;
                if(self.waitingToReset){
                    [self resetCount];
                    return;
                }
            }];
        }];
    }

}

- (void) resetCount
{
    if([NSString isValid: self.savedCountLabel.text] || (!self.hidden && self.superview))
    {
        if(self.canAnimateLikedNumber)
        {
            self.canAnimateLikedNumber = FALSE;

            CGSize defaultSize = [NotificationBadge DefaultBadgeSize];

            CGRect originalRect = CGRectMake(self.frame.origin.x, self.frame.origin.y, defaultSize.width, defaultSize.height);
            [UIView animateWithDuration:0.2 delay:0.0f options:UIViewAnimationOptionLayoutSubviews animations:^{ //squash and stretch
                [self setTransform:CGAffineTransformMakeScale(2, 2)];
            }
            completion:^(BOOL finished)
            {
                [UIView animateWithDuration:0.4 delay:0.0f options:UIViewAnimationOptionLayoutSubviews animations:^{
                    [self setTransform:CGAffineTransformMakeScale(0.0,0.0)];
                    [self setAlpha:0.0f];
                }
                completion:^(BOOL finished)
                {
                    [self setHidden:TRUE];
                    [self setTransform:CGAffineTransformMakeScale(1.0,1.0)];

                    [self setFrame:originalRect];
                    [self.savedCountLabel setText:@"0"];
                    [self.savedCountLabel setFrame:CGRectMake(NOTIFICATION_LABEL_INSETS.left, NOTIFICATION_LABEL_INSETS.top, defaultSize.width - NOTIFICATION_LABEL_INSETS.left - NOTIFICATION_LABEL_INSETS.right, defaultSize.height - NOTIFICATION_LABEL_INSETS.top - NOTIFICATION_LABEL_INSETS.bottom)];

                    self.canAnimateLikedNumber = TRUE;
                    self.waitingToReset = FALSE;

                }];
            }];
        }
        else
        {
            self.waitingToReset = TRUE;
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-16 06:14:14

我想通了。显然,如果您在iOS 5.0+中使用transform属性,则无法将transform值设置为0.0f。

记入animation working in iOS6, buggy in iOS5

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16448450

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档