简体   繁体   中英

iOS - can't tap UIView during a UIViewAnimation with a scale transform

I have this 'flash' animation which makes the view (with tap recogniser) get bigger and smaller by CGAffineTransformMakeScale and UIViewAnimation. The problem is the user can't tap the button while it's still doing the animation.

How do I fix this? Do I have to run the flash methods asynchronously (or is UIViewAnimation already async).

If you are using the block animation method (which you should be) then you can add the option UIViewAnimationOptionAllowUserInteraction .

This will allow taps while the animation is in progress.

You can read the docs here... https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/occ/clm/UIView/animateWithDuration:delay:options:animations:completion :

The method is...

+ (void)animateWithDuration:(NSTimeInterval)duration
                  delay:(NSTimeInterval)delay
                options:(UIViewAnimationOptions)options
             animations:(void (^)(void))animations
             completion:(void (^)(BOOL finished))completion

On my iPad atm but there are dress of tutorials about using this method if you're not already. (And if you're not then you should be).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM