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
2
votes
1 answer

Animate UIView horizontally using UIDynamicAnimator

I have gone through the documentation, and I am embarrassed to say I am confused. The Scenario: I have a UIView, that acts like a container for 3 UIButtons. This container is initially of bounds {0, 0, 35, 35}, with each button inside with the same…
n00bProgrammer
  • 4,261
  • 3
  • 32
  • 60
2
votes
0 answers

Is it possible to toggle slow animation for a spring animation

In iOS simulator there is an option for turning on slow animations. I see that if I create an animation with UIView's animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion: this debug option does not…
Mihai Damian
  • 11,193
  • 11
  • 59
  • 81
2
votes
0 answers

UIDynamics with Core Animation

I have used UIDynamics before, but I never used it along with the methods provided by the Core Animation framework. I basically would like to achieve something very simple: I would like my UI Object to travel along a path and have another UI Object…
Unheilig
  • 16,196
  • 193
  • 68
  • 98
2
votes
0 answers

Is UIKit Dynamics built on top of the SpriteKit framework?

We need to port UIKit Dynamics to MacOS, we already ported it using the low level Box2D C++ library but I wondering if the porting could be easier to do and better to maintain using SpriteKit on Mac.
Marco
  • 783
  • 5
  • 21
2
votes
2 answers

UISnapBehaviour in x-axis only

Is there anyway to get UISnapBevahiour to only work along a linear x-axis? I want the exact behaviour of a UISnapBehaviour but don't want it to 'shake' into position on both x & y axis, just the x axis. This is for a UIView inside my contentView of…
JMWhittaker
  • 3,633
  • 3
  • 23
  • 30
2
votes
1 answer

Implementing swipe on view on top of UICollectionViewCell without swiping during scrolling

I'm using UIPanGestureRecognizer to pan my contentView on a UICollectionViewCell. I'm implementing a swipe gesture, from both sides. I'm using a pan because I want to be able to bounce (animate) the view back to its origin. The UICollectionView is a…
2
votes
1 answer

Attract two masses to each other w/ UIKit Dynamics

Is there any way to attract two masses to each other as if in free space using UIKit Dynamics? I know by default the gravity behaviour acts as if the gravity is pointing down to the earth. But this seems only useful for a small class of behaviours.…
Arjun Mehta
  • 2,500
  • 1
  • 24
  • 40
2
votes
1 answer

Problems with UICollisionBehavior

I'm not sure if I've simply found a few bugs in UICollisionBehavior or if I'm just not implementing it correctly. I am having two main issues. 1) Periodically, I create a UICollisionBehaviors with just two items, a player, and a new item which…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
2
votes
1 answer

UIKit Dynamics doesn't allow me to animate a UIView's centre

I have a UIView which is attached to a UICollisionBehavior. I'm trying to animate its center when a new location is tapped on the screen, but it appears using this block of code is not the way to do it: [UIView animateWithDuration:0.7f …
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
2
votes
1 answer

UIDynamics : Spring

I am trying to create some animation in an iOS app I am developing. I have a box that falls until it collides with a bar. I also added a bounce to the box for the impact on the bar. What I am trying to add now is a behavior on the bar so when the…
BDGapps
  • 3,318
  • 10
  • 56
  • 75
1
vote
1 answer

How to make UIImageView animation wait for dynamicAnimator behavior to finish to start animating

I'm working on an animation for an app, where a shoe box falls from the top of the screen and lands on a pedestal, then the box opens. I was wondering if there was any way to make the animation for opening the box to wait for the box to get settled…
1
vote
1 answer

Swift UIKit dynamics - Vary UIPushBehavior force magnitude by distance from center of source

Can someone suggest how I can vary the UIPushBehavior magnitude force by distance from source. To mirror the affect of the force of wind from a fan on another object. So the closer the object is to the fan the stronger the force. if…
Guitarman4
  • 33
  • 5
1
vote
0 answers

Wrong frame from layoutAttributesForItem when using UICollectionViewFlowLayout with an UIDynamicAnimator

So I implemented an UICollectionView with a custom UICollectionViewFlowLayout containing a UIDynamicAnimator for animating my cells upon scrolling. I used the 2013 WWDC reference to replicate the Message bounce. Everything is working fine, except…
Cerise
  • 383
  • 3
  • 16
1
vote
0 answers

Strange behavior of the "offsetFromCenter" property of UIAttachmentBehavior

I was learning Matt Neuburg's book ios 13 Dive deep into views and stumbled upon example "dragByAttachment". Here: @IBAction func dragging(_ p: UIPanGestureRecognizer) { switch p.state { case .began: self.anim =…
Ninja
  • 309
  • 7
  • 26
1
vote
0 answers

UIKit Dynamics in Collection View always ends in chaos

When scrolling with my "springy flow layout" (meant to replicate the scrolling effect in Messages), the initial scroll works well, but repeated scrolling ends with all of the cells constantly bouncing all over the screen, and off the vertical…
jjatie
  • 5,152
  • 5
  • 34
  • 56