Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-10-2011, 01:05 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 218
malaki1974 is on a distinguished road
Default Wrote a crossfade function but want to load images from array

This code works great crossfading 2 uiimageviews. I would like to use only the two uiimageviews but swap the content before they fade back in so I could have an unlimited amount (although for my purpose I am only going to be using 5-10). Any ideas on how to iterate through an array of images within this code?

Code:
-(void)crossFade {
	
	if (kenBurns1.alpha == 1.0) {
		kenBurns2.alpha = 1.0;
		UIViewAnimationOptions options = UIViewAnimationOptionAllowUserInteraction || UIViewAnimationOptionCurveEaseOut;
		[UIView animateWithDuration:0.5 delay:0.0 options:options 
						 animations:^{
								 
							 kenBurns1.alpha = 0.0;
						 }
						 completion:^(BOOL finished){
							 [kenBurns1 removeFromSuperview];
							 [self.view insertSubview:kenBurns1 atIndex:0];
						 }];
		
	} else if (kenBurns1.alpha == 0.0) {

		kenBurns1.alpha = 1.0;
		
		UIViewAnimationOptions options = UIViewAnimationOptionAllowUserInteraction || UIViewAnimationOptionCurveEaseOut;
		[UIView animateWithDuration:0.5 delay:0.0 options:options 
						 animations:^{
								
							 kenBurns2.alpha = 0.0;						 
						 }
						 completion:^(BOOL finished){
								 
							 [kenBurns2 removeFromSuperview];
							 [self.view insertSubview:kenBurns2 atIndex:0];

						 }];
	}
	
}
malaki1974 is offline   Reply With Quote
Old 03-16-2011, 11:03 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 218
malaki1974 is on a distinguished road
Default Bump...

Just trying to bump it back into view
malaki1974 is offline   Reply With Quote
Old 03-16-2011, 01:06 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 218
malaki1974 is on a distinguished road
Default

While bumping I took a fresh look again and might have solved it. I am sure it could be improved but...

kenburns1 is overtop of kenburns2. They switch z positions and get a new image and then fade - rinse and repeat. I will add scaling to fully recreate the kenburns effect but this is working for me.

Code:
-(void)crossFade {
	
	NSArray *imgArray = [NSArray arrayWithObjects:
						 [UIImage imageNamed:@"image4_large.png"], 
						 [UIImage imageNamed:@"image5_large.png"], 
						 [UIImage imageNamed:@"image9_large.png"],
						 [UIImage imageNamed:@"toc_gallery01.jpg"], 
						 [UIImage imageNamed:@"toc_gallery02.jpg"], 
						 nil];
	
	if (kenBurns1.alpha == 1.0) {
		
		kenBurns2.alpha = 1.0;
		UIViewAnimationOptions options = UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseOut;
		[UIView animateWithDuration:1.0 delay:0.0 options:options 
						 animations:^{
							 kenBurns1.alpha = 0.0;
						 }
						 completion:^(BOOL finished){
							 [kenBurns1 removeFromSuperview];
							[self.view insertSubview:kenBurns1 atIndex:0];
							kenBurns1.image = [imgArray objectAtIndex:view1Index];
							 if (view1Index == 4) {
								 view1Index = 0;
							 } else {
								 view1Index++;
							 }
						 }];
		
	} else if (kenBurns1.alpha == 0.0) {

		kenBurns1.alpha = 1.0;
		
		UIViewAnimationOptions options = UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseOut;
		[UIView animateWithDuration:1.0 delay:0.0 options:options 
						 animations:^{
							kenBurns2.alpha = 0.0;						 
						 }
						 completion:^(BOOL finished){
							[kenBurns2 removeFromSuperview];
							[self.view insertSubview:kenBurns2 atIndex:0];
							 kenBurns2.image = [imgArray objectAtIndex:view2Index];
							 if (view2Index == 4) {
								 view2Index = 0;
							 } else {
								 view2Index++;
							 }
						 }];
	}
}
malaki1974 is offline   Reply With Quote
Reply

Bookmarks

Tags
crossfade, ken burns, uiimageview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 366
13 members and 353 guests
Absentia, akphyo, apatsufas, BinHex, fredidf, Gaz, gmarro, jeroenkeij, Kirkout, MarkC, mottdog, whitey99, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:22 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0