uikit-dynamics

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

这一生的挚爱 提交于 2020-01-02 03:16:08
问题 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 removing the behaviours from the dynamic animator and then re-adding them like this: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.dynamicAnimator removeBehaviour: self.behaviour1]; [self.dynamicAnimator removeBehaviour:

UIDynamicItem update transform manually

淺唱寂寞╮ 提交于 2020-01-01 09:24:14
问题 I know that external change to center , bounds and transform will be ignored after UIDynamicItem s 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 once. So any idea? Thanks. 回答1: Any time you change one of the animated properties, you need to call [dynamicAnimator updateItemUsingCurrentState:item] to let the dynamic animator know you did it. It'll update it's internal representation to

Implement UIKitDynamics for dragging view off screen

Deadly 提交于 2019-12-29 10:07:08
问题 I'm trying to figure out implement UIKit Dynamics that are similar to those in Jelly's app (specifically swiping down to drag view off-screen). See the animation: http://vimeo.com/83478484 (@1:17) I understand how UIKit Dynamics work, but don't have a great physics background and therefore am having trouble combing the different behaviors to get the desired result! 回答1: This sort of dragging can be accomplished with an UIAttachmentBehavior where you create the attachment behavior upon

Collision not working between items

主宰稳场 提交于 2019-12-24 16:36:55
问题 I'm using UIDynamics in my app. my app has two squares. one is fixed and the other can be moved (by applying a pan gesture). when i try to collide them they don't collide. the delegate methods never get called. here's my code and i hope someone can point out the problem. UIDynamicAnimator* animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view]; UICollisionBehavior* collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[self.square1, self.square2]]; collisionBehavior

How do i make a circular view collide with the paddle

本小妞迷上赌 提交于 2019-12-23 13:09:10
问题 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 arrow is the colliding point, As it does not seem to be colliding with ball instead it collides with the frame of the view. once, the frame is touched with the paddle it bounces back and so on. 回答1: If you're using UIDynamicAnimator , you can define

How to replicate Messages bouncing bubbles in iOS 7

落花浮王杯 提交于 2019-12-17 22:21:49
问题 When you are in a conversation within the Messages app in iOS 7, if you scroll up or down you will notice that the bubbles and more so the text saying when the messages were sent, will bounce into place. I am trying to replicate this in my own table view, but am not finding a way to do it. I assume it is using UIDynamics, but I am not sure how to tie that in with the scrolling and the content bouncing. Any help would be appreciated 回答1: If you want to replicate that effect yourself, you need

UIDynamicItem with non-rectangular bounds

强颜欢笑 提交于 2019-12-11 18:54:15
问题 So I'm looking into UIKit Dynamics and the one problem I have run into is if I want to create a UIView with a custom drawRect: (for instance let's say I want to draw a triangle), there seems to be no way to specify the path of the UIView (or rather the UIDynamicItem) to be used for a UICollisionBehavior. My goal really is to have polygons on the screen that collide with one another exactly how one would expect. I came up with a solution of stitching multiple views together but this seems like

UIKit Dynamics change a view frame with collisions

心已入冬 提交于 2019-12-11 14:29:07
问题 My project has several views that are subject to radial gravity at the center of their parent view, and elastic collisions so that they don't overlap. It works great, but sometimes I need to resize the views, and, when a view gets larger, the other views must move away from it so that all the views remain non-overlapping. I would expect the collision behavior to realize things are touching and to move them apart, but it doesn't seem to. Here's what I'm trying now: [UIView animateWithDuration

iOS: UIDynamicAnimator updateItemUsingCurrentState not working with rotation

牧云@^-^@ 提交于 2019-12-11 12:12:14
问题 I am trying to manually change rotation of a view in UIDynamics , but the view's rotation is always reset after update. The documentation says, that UIDynamicAnimator 's updateItemUsingCurrentState: method should update position and rotation of an item, but only position is updated. I created a short example where a square view is falling from the screen and after a touch it should be positioned to the location of the touch and rotated to 45 degrees. However, no rotation happens (sometimes

UIDynamicAnimator items(in:) crashes in iOS 11

烂漫一生 提交于 2019-12-11 04:23:10
问题 In iOS 11 (Xcode 9 beta 5), I'm calling UIDynamicAnimator's items(in:) method and immediately crashing: NSArray element failed to match the Swift Array Element type What's going on? 回答1: You've found a bug. (Filed with Apple, radar 33979954.) Hopefully it will be fixed soon, but until then, here's the fix: extension UIDynamicAnimator { func views(in rect: CGRect) -> [UIView] { let nsitems = self.items(in: rect) as NSArray return nsitems.flatMap{$0 as? UIView} } } Now call view(in:) instead of