繁体   English   中英

UIButton的动画会减小其大小

[英]Animation of UIButton decreases its size

这是我正在制作动画的一个小片段视图:

动画闪光灯

在此处输入图片说明

我在从制作动画时遇到问题吗? 反之亦然。 我正在设置适当的帧以离开屏幕,然后从其他尺寸重新打开。 为什么黑色按钮的大小随其移动而减小?

-(void)moveToRight
{
//just made this method up, but my actual code
//special case
if (currentDay == 7) {
    //move off the screen to the right
    CGRect offScreenRightFrame = CGRectMake(self.circle.frame.origin.x + 60, self.circle.frame.origin.y, self.circle.frame.size.width, self.circle.frame.size.height);
    //move to the left of the screen so we can animate it in
    CGRect offScreenLeftFrame = CGRectMake(-40, self.circle.frame.origin.y, self.circle.frame.size.width, self.circle.frame.size.height);

    if (self.delegate) {
        if ([self.delegate respondsToSelector:@selector(dayChangedTo:)]) [self.delegate dayChangedTo:[self getCurrentDay]];
    }

    [self pulseCircle];
    [UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^{
        self.circle.frame = offScreenRightFrame;
    }completion:^(BOOL finished) {
        if (finished) {
            self.circle.alpha = 0.0f;
            self.circle.frame = offScreenLeftFrame;
            [UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^{
                self.circle.center = self.labelSun.center;
                self.circle.alpha = 1.0f;
            }completion:^(BOOL finished) {
                if (finished) {
                    [UIView animateWithDuration:0.25f animations:^{
                        [self changeColors];
                        [self pulseCircle];
                    }];
                }
            }];
        }
    }];
}

-(void)moveLeft
{
if (currentDay == 8) {

    CGRect circleFrame = self.circle.frame;

    CGRect offScreenLeft = CGRectOffset(circleFrame, -20, 0);
    CGRect offScreenRightFrame = CGRectMake(self.labelQuestion.frame.origin.x + 30, self.labelQuestion.frame.origin.y, circleFrame.size.width, circleFrame.size.height);

    [self pulseCircle];
    [UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^{
        self.circle.frame = frame;
    }completion:^(BOOL finished) {
        if (finished) {
            self.circle.alpha = 0.0f;
            self.circle.frame = frameFinal;
            [UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^{
                self.circle.center = self.labelQuestion.center;
                self.circle.alpha = 1.0f;
            }completion:^(BOOL finished) {
                if (finished) {
                    [UIView animateWithDuration:0.25f animations:^{
                        [self changeColors];
                        [self pulseCircle];
                    }];
                }
            }];
        }
    }];
}


- (void)pulseCircle 
{ 
__block UILabel *day = [self getLabelOfDay];
[UIView animateWithDuration:TRANLATE_DURATION/2 delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState animations:^{
    self.circle.layer.transform = CATransform3DMakeScale(1.35f, 1.35f, 1);
    day.transform = CGAffineTransformMakeScale(1.35f, 1.35f);
}completion:^(BOOL finished) {
        [UIView animateWithDuration:TRANLATE_DURATION/2 animations:^{
            self.circle.layer.transform = CATransform3DIdentity;
            day.transform = CGAffineTransformIdentity;
        }];
}];
}

我只是把我的逻辑..老实说,我不读/没有看到您的代码/逻辑,但可能是我的主意;)所以,我认为..您应该在公共变量中添加圆的大小作为默认大小。 并随时根据需要设置此大小。

if (currentDay == 0 || currentDay == 8)
{
   // Here you need to set your default size.
}

可能是我的逻辑工作,因为17天工作正常,但是当currentDay08天丰富时创建了问题。

谢谢 :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM