Questions tagged [uikit-dynamics]

UIKit Dynamics is a feature introduced in iOS 7 that enables dynamic behaviors, which offers a way to enhance the user experience by incorporating real-world behaviors and characteristics, such as gravity, into your animations.

UIKit Dynamics is "a composable, reusable, declarative, real-world inspired animation, and interaction system" (as described in WWDC 2013 video, Getting Started with UIKit Dynamics).

Any object that conforms to the UIDynamicItem protocol, such as UIView objects, can be associated with "behaviors" that can be added to a dynamic animator, a UIDynamicAnimator. These behaviors include forces, elasticity, gravity, collisions, etc.

The types of behavior objects which can be added to the UIDynamicAnimator object include UIAttachmentBehavior, UICollisionBehavior, UIDynamicItemBehavior, UIGravityBehavior, UIPushBehavior, and UISnapBehavior. You can also combine these behaviors together or create your own custom dynamic behaviors.

UIKit Dynamics is not designed to replace Core Animation or UIView animations, but is designed to offer another mechanism to easily create more interactive and dynamic animations with less code. Likewise, UIKit Dynamics is not intended to replace SpriteKit, which might be better suited for many games.

Resources:

Related tags:

203 questions
9
votes
5 answers

Disable rotation on a UISnapBehavior?

I like that UISnapBehavior snippet, but I really want to use it to slide in one direction only with a slight oscillation. Is there a way to turn off rotation for this behavior? As SpriteKit has allowsRotation property which can be easily turned off.
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
7
votes
3 answers

Setting collision bounding path of a UIView in iOS 9

In iOS 9 Apple introduced the collisionBoundsType to UIKit-Dynamics. I have no issue when setting this UIDynamicItemCollisionBoundsTypeRectangle or when I set this to UIDynamicItemCollisionBoundsTypeEllipse. The screenshot below is from a game I am…
Wyetro
  • 8,439
  • 9
  • 46
  • 64
7
votes
3 answers

UIDynamicItem update transform manually

I know that external change to center, bounds and transform will be ignored after UIDynamicItems init. But I need to manually change the transform of UIView that in UIDynamicAnimator system. Every time I change the transform, it will be covered at…
xiaobo
  • 93
  • 8
7
votes
4 answers

CollectionView + UIKit Dynamics crashing on performBatchUpdates:

I'm stucked with a strange crash and trying to fix it all day long. I have a custom UICollectionViewLayout that basically adds gravity and collision behavious to the cells. The implementation works great! The problem happens when I try to delete one…
6
votes
1 answer

Why UIKit Dynamics doesn`t work?

I am studying iOS development now. When I add a rect view and want it be effected by the gravity, build and run my test app, I find it does`t have the gravity. This is the viewDidLoad code in my viewController.m : [super viewDidLoad]; // Do any…
Morgan Deng
  • 103
  • 7
6
votes
1 answer

Animate Auto Layout backed view using UIKitDynamics

I'd like to use a UIKitDynamics UISnapBehaviour to spice up the animation (appearance + position change on rotation) of a button that itself is positioned in a view using Auto Layout. I understand that while applying UIKitDynamics forces I need to…
Bernd
  • 11,133
  • 11
  • 65
  • 98
6
votes
0 answers

Is it possible to pause a UIDynamicAnimator without removing and adding UIDynamicBehaviours?

I'm implementing some animations using UIDynamics to enable some physics-based transitions between views. I'd like to pause and continue these animations programatically in response to user touches. The only way I've found to do this so far is by…
rankAmateur
  • 2,067
  • 2
  • 18
  • 22
5
votes
1 answer

Combining UIAttachmentBehavior and UICollisionBehavior

Using UIKit Dynamics I want to combine a UIAttachmentBehavior and UICollisionBehavior in a way such that the user can drag a view around (using a UIPanGestureRecognizer) but not leave a certain area. The problem arises, when the user/UIView collide…
Timm
  • 2,652
  • 2
  • 25
  • 34
5
votes
3 answers

UIDynamics and Device Rotation

If I add any kind of UIDynamicBehavior to my views, it completely breaks things when the device is rotated. Here's what it is in portrait (displaying correctly): And here it is in landscape, all broke: I don't believe it's an autolayout issue…
swilliams
  • 48,060
  • 27
  • 100
  • 130
4
votes
1 answer

In Swift’s UIKit Dynamics, how can I define a circle boundary to contain a UIView?

I have researched a LOT, but the only examples I can find anywhere are for the purpose of defining the bounds of a UIView so that they collide/bounce off each other on the OUTSIDE of the objects. Example: A ball hits another ball and they bounce…
Justin
  • 319
  • 3
  • 13
4
votes
2 answers

How do i make a circular view collide with the paddle

Whenever the circular view collides with the paddle on storyboard, it actually collides with the rectangular frame of the view. How do I resolve this issue. I have also tried UIBezierPath, CAShapeLayer and it doesn't seem to be working. The red…
govind kumar
  • 205
  • 4
  • 12
4
votes
1 answer

UIDynamicAnimator Shake with spring effect

I'm trying to replace my core animation shake effect in this code let shake = CAKeyframeAnimation(keyPath: "position.x") shake.values = [0, 20, -20, 20, -15, 15, -5, 5, 0] shake.keyTimes = [0, 1/10.0, 3/10.0, 5/10.0, 6/10.0, 7/10.0,…
imObjCSwifting
  • 743
  • 1
  • 12
  • 34
4
votes
1 answer

How to make multiple UIImages fall with gravity at the same time?

As the user taps on superview I am detecting it via UITapGestureRecognizer and calling below function to create a UIImage view, add it to superview, add gravity to it and let it fall out of the superview. Problem is that if the user taps again while…
Kashif
  • 4,642
  • 7
  • 44
  • 97
4
votes
1 answer

Shake a UIView ... BUT using UIKit Dynamics

There are many situations where you need to "shake" a UIView. (For example, "draw child user's attention to a control", "connection is slow", "user enters bad input," and so on.) Would it be possible to do this using UIKit Dynamics? So you'd have to…
Fattie
  • 27,874
  • 70
  • 431
  • 719
4
votes
2 answers

UIDynamics and Autolayout

Recently I used UIDynamics to animate an image view into place. However, because its autolayout y-pos constraint was set to off-screen, when navigating away from the screen and then returning to it, my image view was being placed off-screen again.…
jancakes
  • 456
  • 4
  • 10
1
2
3
13 14