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
1
vote
1 answer

Resize UIView with UICollisionBehavior

I'm recently trying to create a little pong-like game with UIKitDynamics. I succeeded in building up the core game. Now I want to add some additional mechanics. For example a behaviour, that decrease the size of the paddle. I have added a NSTimer…
Tom Kuschka
  • 463
  • 1
  • 8
  • 17
1
vote
0 answers

UICollectionView Spring Flow Layout with UIDynamics: minimum space between cells

Im trying to get this effect: http://cl.ly/0W2B2k0a3l2H Im using this code, conferring a spring effect with UIAttachmentBehavior: https://github.com/noiis/SpringFlowLayout/blob/master/SpringFlowLayout.swift Despite the effects are similar, there are…
Damasio
  • 496
  • 5
  • 14
1
vote
2 answers

How do you update UIView layout when using UIKit Dynamics?

I have a custom UIView using UIKit Dynamics to perform an animation when the user taps on a button. The view in question is a simple one, that I lay out manually in layoutSubviews(). However, layoutSubviews() gets called for each frame of animation…
Dov
  • 15,530
  • 13
  • 76
  • 177
1
vote
1 answer

UICollisionBehavior only works after adding the first time

My app has a custom UIButton with two subviews that look like they're hanging by strings. When the user taps the button, one gets pulled back, then collides with the other. This is working for me on the first collision, but when I go to tap a second…
Dov
  • 15,530
  • 13
  • 76
  • 177
1
vote
1 answer

Swift Collision Boundary not working

Swift 2.0, xcode 7, Ios 9 Intention: I want the two squares to drop to the bottom and stay at the bottom of the screen. What is happening now: There is no error preventing the code from running, the gravity works fine but the collision just seems to…
jim layhey
  • 91
  • 7
1
vote
2 answers

How to make UICollectionView bounce to illustrate scrollability?

I've seen a number of apps where, when you launch them for the first time, they make something move or bounce to demonstrate that you can scroll something that might not be clear at first glance. I have a UICollectionView that displays a single…
Ken A
  • 83
  • 9
1
vote
0 answers

How to Iisten to UIView changes made by an itemBehavior like UISnapBehavior

I want to darken the background color of a view depending on the position of the view. I darken the view using a gesture recognizer, when dragging to the right it gets darker by subclassing the UIView and overriding the layoutSubviews method. But if…
Vladislav
  • 1,392
  • 1
  • 12
  • 21
1
vote
0 answers

UIDynamicAnimator with layoutSubviews laggy

I try to implement side bar menu. I already have done it with standard UIView animations, but now i want to add some feelings to it. I decided to use UIViewDynamics. I noticed that, after main view frame changed, it is necessary to recreate…
1
vote
1 answer

UIAttachmentBehavior not working for pong AI that can lose

So I am trying to implement a basic pong AI that is decent, but can be beaten. I have tried [UIView animateWithDuration...] UISnapBehavior and UIAttachmentBehavior. animateWithDuration does not update the collision detection properly so i get…
MadeByDouglas
  • 2,509
  • 1
  • 18
  • 22
1
vote
2 answers

UICollectionViewFlowLayout: collectionView!.contentSize vs collectionViewContentSize

Update The issue seems to be resolved when using the designated collectionViewContentSize() method like so: let contentSize = collectionViewContentSize() Nevertheless, I would be very interested in an explanation behind this behaviour, so I've…
1
vote
0 answers

Can we apply gravity behavior to centre of screen?

I am using uidynamicbehavior (UIGravityBehavior) . I played with gravityDirection but could not make it focused on the centre of the screen. Is there any way around to make the gravity focused in the centre on the screen. Basically what I want is to…
user3804063
  • 809
  • 1
  • 14
  • 32
1
vote
0 answers

SpriteKit and UIDynamics together are acting strange

I'm trying to use UIDynamics in one view controller and when I push another view controller that contains SKView with scene that uses physics, it acts weird. If I disable UIDynamics on previous controller and comment this line: _animator =…
Test User
  • 125
  • 2
  • 12
1
vote
1 answer

Rotating an UIView using UIDynamics and gravity from CMMotionManager

I have an UIView which is a picture frame hanging on a nail from a string. I'm trying to rotate the view around its anchorPoint to keep the view's bottom flat(parallel with the ground) regardless of the devices rotation. I'm trying to achieve this…
1
vote
1 answer

Is it possible to add multiple UIGravityBehaviors to a UIDynamicAnimator?

I'm trying to create a view where some items fall along normal gravity vector and others fall along an opposite vector self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self]; // Normal Gravity self.gravityBehavior =…
Warpling
  • 2,024
  • 2
  • 22
  • 38
1
vote
1 answer

joystick for user control in iOS8 scenekit

I am developing one game similar to bubble island(https://itunes.apple.com/in/app/bubble-island/id531354582?mt=8). In this I want to create control like when user click on any part of view, game displays the series of bubbles in the touch…
M007
  • 580
  • 1
  • 5
  • 24