2014-01-06 2 views
0

Вот небольшой клип вид анимируемого мной:Анимация UIButton уменьшает его размер

Animation flash

enter image description here

У меня возникают проблемы при анимации из? к S и наоборот. Я устанавливаю соответствующие кадры для выхода из экрана, а затем обратно из другого размера. Почему размер черной кнопки уменьшается при каждом движении вокруг него?

-(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; 
     }]; 
}]; 
} 
+0

self.circle.frame = frame .... какова рамка, где вы это заявили? – jailani

ответ

0

я просто положил мою логику .. честно я не прочитал/см ваш код/​​логики, но может быть моя идея работы для вас;) Так что, я думаю .. вы должны добавить размер круга в public variable в качестве размера по умолчанию. И установите этот размер, когда вы богаты.

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

Может быть моя логика работы для вас, потому что к день его работы хорошо, но проблема в том, когда создается currentDay обогащаться или день.

Thanks :)

Смежные вопросы