Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 84

NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
05/17/14 06:40 AM (10 years ago)

small animations in iOS 7 (like animated gif)

Was starting to look at adding some small animations to my app, and of course it is not as simple as dropping in an animated GIF in place of a png OR jpg... Found some interesting links for iOS7. Several different ways of achieving the effect, but the following link was one of the best at explaining and showing code example. Look at step #4 in the following link. It should work great: http://www.icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/ UPDATE: Posted code with sample animation lower in the thread
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
05/17/14 02:51 PM (10 years ago)
Maybe Chris will enhance the Image View in Ultimate Screen Creator to include an animation described by an array of images (like in an XIB), and BT3 apps will start showing a lot more animations ;) I would have no problem paying an upgrade for that feature in v2 of USC.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
05/17/14 03:31 PM (10 years ago)
lol - no way to charge for upgrades on plugins. Would be a nice feature for the plugin market though... The way I've done what you're talking about before is to animate a series of images as frames from a short video. Check out my animated splash screen plugin for an example of how this works.
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
05/17/14 04:45 PM (10 years ago)
Will do. Especially since the Splash is one of the three screens that I was looking to put the first animations on.
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
05/17/14 08:47 PM (10 years ago)
OLD Question: Does the Animated Splash Screen enable you to have an animation that is NOT full screen? The description doesn't list an XIB- can you position the animation via x,y? = NO EDIT: Purchased. However the Animated Splash uses the whole background. I have a single image that I am using for Launch, etc and Home Screen, and layering items on top. Looking to achieve classic smaller animations (fist one would be company logo that does not need to waste a ton of room to store images.) The article above worked well, easy to implement. However since they suggested placing in ViewDidLoad there really needs to be other references to Start and Stop. For example since I don't have variables declared correct for that, not sure how to add [ryuJump stopAnimating] in viewWillDisappear. - (void)viewDidLoad { [super viewDidLoad]; NSArray * imageArray = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"1.png"], [UIImage imageNamed:@"2.png"], [UIImage imageNamed:@"3.png"], [UIImage imageNamed:@"4.png"], [UIImage imageNamed:@"5.png"], [UIImage imageNamed:@"6.png"], [UIImage imageNamed:@"7.png"], [UIImage imageNamed:@"8.png"], [UIImage imageNamed:@"9.png"], [UIImage imageNamed:@"10.png"], [UIImage imageNamed:@"11.png"], [UIImage imageNamed:@"12.png"], nil]; UIImageView * ryuJump = [[UIImageView alloc] initWithFrame: CGRectMake(100, 125, 150, 130)]; ryuJump.animationImages = imageArray; ryuJump.animationDuration = 1.1; ryuJump.contentMode = UIViewContentModeBottomLeft; //ryuJump.animationRepeatCount = 0; //default is 0 for repeat [self.view addSubview:ryuJump]; [ryuJump startAnimating]; } ====== Here is a .mov of the above code/animation from the simulator: https://www.dropbox.com/s/oml85i7ihteppbu/Animation.mov not sure why the video shows up so big. actual animation is only 150w x 130h (first try using quicktime)
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
05/19/14 07:14 AM (10 years ago)
don't worry ARC will remove the UImageView on view will disappear. but if you do want to control it just a property in the .h @property (nonatomic, retain) UIImageView * ryuJump; Then in the viewdidload NSArray * imageArray = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"1.png"], [UIImage imageNamed:@"2.png"], [UIImage imageNamed:@"3.png"], [UIImage imageNamed:@"4.png"], [UIImage imageNamed:@"5.png"], [UIImage imageNamed:@"6.png"], [UIImage imageNamed:@"7.png"], [UIImage imageNamed:@"8.png"], [UIImage imageNamed:@"9.png"], [UIImage imageNamed:@"10.png"], [UIImage imageNamed:@"11.png"], [UIImage imageNamed:@"12.png"], nil]; ryuJump = [[UIImageView alloc] initWithFrame: CGRectMake(100, 125, 150, 130)]; ryuJump.animationImages = imageArray; ryuJump.animationDuration = 1.1; ryuJump.contentMode = UIViewContentModeBottomLeft; //ryuJump.animationRepeatCount = 0; //default is 0 for repeat [self.view addSubview:ryuJump]; The you can use [self.ryujump startAnimating]; and [self.ryuJump stopAnimating]; wherever you like in the code. but if it is to just to turn it off when the screen disappears it will do it automatically.
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
05/19/14 03:12 PM (10 years ago)
Good to know that it goes away when view disappears. But what you mentioned about the Property I forgot will let me start-stop and adjust an animation on a screen for an idea I had today. Thanks
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
05/19/14 05:28 PM (10 years ago)
I forgot that I originally had the property line in before and had to remove it? =========================== With the property in the .h @property (nonatomic, retain) UIImageView * ryuJump; and this statement in .m [self.ryujump startAnimating]; Animation does not appear (or animate) ===================== With just this statement in .m [ryujump startAnimating]; Animation appears, and animates from the second time the screen loads onward... ======================
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.