programming4us
programming4us
MOBILE

iPhone Developer : Assembling Views and Animations - Recipe: Fading a View In and Out

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

At times, you want to add information to your screen that overlays your view but does not of itself do anything. For example, you might show a top scores list or some instructions or provide a context-sensitive tooltip. Recipe 1 demonstrates how to use a UIView animation block to fade a view into and out of sight. This recipe follows the most basic animation approach. It creates a surrounding view animation block and then adds the single line of code that sets the alpha property.

One thing this recipe does not do is wait for the animation to finish. The change in the bar button item gets called as soon as the animations are committed, nearly a second before they end. If you tap the Fade In/Fade Out button quickly (you may want to slow the animation duration to see this better), you discover that the new animation starts up, replacing the old one, creating a visual discontinuity.

To address this, you might want to add a call to UIView with setAnimationBeginsFromCurrentState:, setting the argument to YES. This tells the iPhone to use the current state of the ongoing animation to start the next animation, avoiding that jump.

Recipe 1. Animating Transparency Changes to a View’s Alpha Property
@implementation TestBedViewController

- (void) fadeOut: (id) sender
{
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[[self.view viewWithTag:999] setAlpha:0.0f];
[UIView commitAnimations];
self.navigationItem.rightBarButtonItem =
BARBUTTON(@"Fade In",@selector(fadeIn:));
}

- (void) fadeIn: (id) sender
{
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[[self.view viewWithTag:999] setAlpha:1.0f];
[UIView commitAnimations];
self.navigationItem.rightBarButtonItem =
BARBUTTON(@"Fade Out",@selector(fadeOut:));
}

- (void) viewDidLoad
{
self.navigationItem.rightBarButtonItem =
BARBUTTON(@"Fade Out",@selector(fadeOut:));
}
@end

Other  
 
Top 10
Free Mobile And Desktop Apps For Accessing Restricted Websites
MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
TOYOTA CAMRY 2; 2.5 : Camry now more comely
KIA SORENTO 2.2CRDi : Fuel-sipping slugger
How To Setup, Password Protect & Encrypt Wireless Internet Connection
Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
Backup & Restore Game Progress From Any Game With SaveGameProgress
Generate A Facebook Timeline Cover Using A Free App
New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
- Messages forwarded by Outlook rule go nowhere
- Create and Deploy Windows 7 Image
- How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
- Creating and using an unencrypted cookie in ASP.NET
- Directories
- Poor Performance on Sharepoint 2010 Server
- SBS 2008 ~ The e-mail alias already exists...
- Public to Private IP - DNS Changes
- Send Email from Winform application
- How to create a .mdb file from ms sql server database.......
programming4us programming4us
programming4us
 
 
programming4us