Created
May 1, 2013 07:58
-
-
Save kenshin03/5494240 to your computer and use it in GitHub Desktop.
Ken Burns effect on image view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)animateBackground { | |
NSInteger randInt = arc4random()%3; | |
NSInteger translationX = 0; | |
NSInteger translationY = 0; | |
NSInteger scaleX = 0; | |
NSInteger scaleY = 0; | |
switch (randInt) { | |
case 0: | |
translationX = 90; | |
translationY = -100; | |
scaleX = 2.5; | |
scaleY = 2.5; | |
break; | |
case 1: | |
translationX = 20; | |
translationY = -70; | |
scaleX = 2.7; | |
scaleY = 2.7; | |
break; | |
case 2: | |
translationX = 40; | |
translationY = -50; | |
scaleX = 2.0; | |
scaleY = 2.0; | |
break; | |
default: | |
break; | |
} | |
// re-animate image background | |
[UIView animateWithDuration:50.0f | |
delay:0.0f | |
options: | |
UIViewAnimationOptionCurveLinear | | |
UIViewAnimationOptionAutoreverse | | |
UIViewAnimationOptionRepeat | |
animations:^{ | |
[UIView setAnimationRepeatCount:10]; | |
CGAffineTransform moveRight = CGAffineTransformMakeTranslation(translationX, translationY); | |
CGAffineTransform zoomIn = CGAffineTransformMakeScale(scaleX, scaleY); | |
CGAffineTransform transform = CGAffineTransformConcat(zoomIn, moveRight); | |
self.backgroundImageView.transform = transform; | |
} completion:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment