Book Image

Application Development in iOS 7

By : Kyle Begeman
Book Image

Application Development in iOS 7

By: Kyle Begeman

Overview of this book

Table of Contents (15 chapters)
Application Development in iOS 7
About the Author
About the Reviewers

Manipulating item properties

As mentioned before, UIDynamics items have properties that can be manipulated and applied to multiple views/items in your interface. Let's see what it looks like to adjust the elasticity property and apply it to our food image view.

Scroll to viewDidLoad and add the following code to its end:

UIDynamicItemBehavior* itemBehaviour = [[UIDynamicItemBehavior alloc] initWithItems:@[self.foodImageView]];
itemBehaviour.elasticity = 0.6;
[animator addBehavior:itemBehaviour];

Here, we create a UIDynamicItemBehavior instance and initialize it with our self.foodImageView. Next, we set the elasticity property and then add this new behavior to our animator. Go ahead and run your code, and watch how the food image view will now bounce a few extra times. Play with the elasticity value to see different results.

Elasticity is one of the many behaviors that can be altered. The following is a list of all the properties available with UIDynamicItemBehavior:

  • Elasticity: This property...