簡體   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