0
votes

I have a UIView that is moved up via CGRectOffset in a animateWithDuration block when an up swipe is detected. The same view moves down the same way when a down swipe is detected. When a down swipe occurs and the move down animation completes, I call another method that animates a UILabel to shake left to right. This works perfectly on my iphone 5 with ios7, but doesnt work on ios8. Anyone know why? I've heard about CGRectOffset not working with autolayout, but that doesn't explain why I can get it to work on ios7 and not ios8.

-(void) animatePlayLabel
{
    [UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.1 initialSpringVelocity:0.2 options:UIViewAnimationOptionCurveEaseInOut animations:^{

    self.playLabel.frame = CGRectOffset(self.playLabel.frame, -10, 0);
    self.playLabel.frame = CGRectOffset(self.playLabel.frame, +20, 0);
    self.playLabel.frame = CGRectOffset(self.playLabel.frame, -20, 0);
    self.playLabel.frame = CGRectOffset(self.playLabel.frame, +20, 0);
    self.playLabel.frame = CGRectOffset(self.playLabel.frame, -20, 0);
    self.playLabel.frame = CGRectOffset(self.playLabel.frame, +20, 0);
    self.playLabel.frame = CGRectOffset(self.playLabel.frame, -10, 0);

    } completion:^(BOOL finished) {

}];
1

1 Answers

0
votes

You should only set the final value of frame inside a UIView animation block. The fact that you get the result you want in iOS 7 is a fluke - you're using this API incorrectly.

It looks like you want this label to bounce around in place without moving. You could use UIDynamics to easily achieve this effect. (There's plenty of sample code out there.)

If you want finer-grain control over the effect, check out Core Animation's keyframe animations.