programming4us
programming4us
MOBILE

iPhone Developer : Assembling Views and Animations - Display and Interaction Traits, UIView Animations

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

Display and Interaction Traits

In addition to physical screen layout, the UIView class provides properties that control how your view appears onscreen and whether users can interact with it. Every view uses a translucency factor (alpha) that ranges between opaque and transparent. Adjust this by issuing [myView setAlpha:value], where the alpha values falls between 0.0 (fully transparent) and 1.0 (fully opaque). This is a great way to hide views and to fade them in and out onscreen.

You can assign a color to the background of any view. [myView setBackgroundColor: [UIColor redColor]] colors your view red, for example. This property affects different view classes in different ways depending on whether those views contain subviews that block the background. Create a transparent background by setting the view’s background color to clear (i.e. [UIColor clearColor]).

Every view, however, offers a background color property regardless of whether you can see the background. Using bright, contrasting background colors is great way to visually see the true extents of views. When you’re new to iPhone development, coloring in views offers a concrete sense of what is and is not onscreen and where each component is located.

The userInteractionEnabled property controls whether users can touch and interact with a given view. For most views, this property defaults to YES. For UIImageView, it defaults to NO, which can cause a lot of grief among beginning developers. They often place a UIImageView as their backsplash and don’t understand why their switches, text entry fields, and buttons do not work. Make sure to enable the property for any view that needs to accept touches, whether for itself or for its subviews, which may include buttons, switches, pickers, and other controls. If you’re experiencing trouble with items that seem unresponsive to touch, you should check the userInteractionEnabled property value for that item and for its parents.

Disable this property for any display-only view you layer over your interaction area. To show a noninteractive clock via a transparent full-screen view, unset interaction. This allows touches to pass through the view and fall below to the actual interaction area of your application.

UIView Animations

UIView animation provides one of the odd but lovely perks of working with the iPhone as a development platform. It enables you to slow down changes when updating views, producing smooth animated results that enhance the user experience. Best of all, this all occurs without you having to do much work.

UIView animations are perfect for building a visual bridge between a view’s current and changed states. With them, you emphasize visual change and create an animation that links those changes together. Animatable changes include the following:

  • Changes in location— Moving a view around the screen

  • Changes in size— Updating the view’s frame and bounds

  • Changes in stretching— Updating the view’s content stretch regions

  • Changes in transparency— Altering the view’s alpha value

  • Changes in states— Hidden versus showing

  • Changes in view order— Altering which view is in front

  • Changes in rotation— Or any other affine transforms that you apply to a view

Building UIView Animation Blocks

UIView animations work as blocks, that is, a complete transaction that progresses at once. Start the block by issuing beginAnimations:context:. End the block with commitAnimations. Send these class methods to UIView and not to individual views. In the block between these two calls, you define the way the animation works and perform the actual view updates. The animation controls you’ll use are as follows:

  • beginAnimations:context Marks the start of the animation block.

  • setAnimationCurve Defines the way the animation accelerates and decelerates. Use ease-in/ease-out (UIViewAnimationCurveEaseInOut) unless you have some compelling reason to select another curve. The other curve types are ease in (accelerate into the animation), linear (no animation acceleration), and ease out (accelerate out of the animation). Ease-in/ease-out provides the most natural-feeling animation style.

  • setAnimationDuration Specifies the length of the animation, in seconds. This is really the cool bit. You can stretch out the animation for as long as you need it to run. Be aware of straining your user’s patience and keep your animations below a second or two in length. As a point of reference, the keyboard animation, when it slides on or offscreen, lasts 0.3 seconds.

  • commitAnimations Marks the end of the animation block.

Sandwich your actual view change commands after setting up the animation details and before ending the animation.

CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];

// View changes go here
[contentView setAlpha:0.0f];

[UIView commitAnimations];

This snippet shows UIView animations in action by setting an animation curve and the animation duration (here, one second). The actual change being animated is a transparency update. The alpha value of the content view goes to zero, turning it invisible. Instead of the view simply disappearing, this animation block slows down the change and fades it out of sight. Notice the call to UIGraphicsGetCurrentContext(), which returns the graphics context at the top of the current view stack. A graphics context provides a virtual connection between your abstract drawing calls and the actual pixels on your screen (or within an image). As a rule, you can pass nil for this argument without ill effect in the latest SDKs.

Animation Callbacks

View animations can notify an optional delegate about state changes, namely that an animation has started or ended. This proves helpful when you need to catch the end of an animation to start the next animation in a sequence. To set the delegate, use setAnimationDelegate:, for example:

[UIView setAnimationDelegate:self];

To set up an end-of-animation callback, supply the selector sent to the delegate.

[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

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