CAAnimation - User Login Disabled

I'm trying to animate a button. When I do this (using button.layer addAnimation), the button becomes disabled. Is there a way to allow user interaction during animation? I also tried to wrap everything in the block using animateWithDuration, passing in the UIViewAnimationOptionAllowUserInteraction option, but it still doesn't work.

EDIT: This is weird. If I clicked in the upper corner (where I placed my button), it fires an event. It's almost like a button frame does not match the animation.

EDIT: what I ended up with was creating an event that fires every 0.1 seconds that sets the button.frame parameter to the frame [[button.layer presentationLayer]]. It seemed like a trick.

0
source share
5 answers

What I ended up with was creating an event that fires every 0.1 seconds that sets button.frame to button.layer

0
source

Use the following UIView method with UIViewAnimationOptionAllowUserInteraction in the UIViewAnimationOptions parameter:

+ (void) animateWithDuration: (NSTimeInterval) delay duration: (NSTimeInterval) delay parameters: (UIViewAnimationOptions) animation options: (void (^) (void)) animation completion: (void (^) (completed BOOL)) completion

0
source

For me, the event seemed a bit hacky.
However, your mention of [[button.layer presentationLayer] frame] led me on the right path [[button.layer presentationLayer] frame]

So, by attaching a gesture recognizer to viewing a moving view, I can make the following detection:

 CGPoint tapLocation = [gestureRecognizer locationInView:self.view]; for (UIView* childView in self.view.subviews) { CGRect frame = [[childView.layer presentationLayer] frame]; if (CGRectContainsPoint(frame, tapLocation)) { .... } } 
0
source

I wanted the button to increase. Therefore, I scale the layer before starting the animation:

 layer.transform = CATransform3DScale (layer.transform, 0.01, 0.01, 0.01); // some animation code 

After the animation, I scaled it.

 // some animation code CATransform3D endingScale = CATransform3DScale (layer.transform, 100, 100, 100); // some animation code [layer addAnimation:animation forKey:@"transform"]; layer.transform = endingScale; 

It looks like if you directly assign it to a layer, the frame will change. However, using animation will not change the frame.

0
source

the best solution is to change the position of the layer after calling the animation:

 [button.layer addAnimation:animation forKey:@"animation"]; button.layer.position = endPosition; 
0
source

Source: https://habr.com/ru/post/896808/


All Articles