简体   繁体   中英

UIButton Custom Highlight

The app I am currently developing uses draggable UIButtons created programmatically. They work very well: after creating them, I add a UIPanGestureRecognizer which enables me to track their position as they are dragged.

I also have added a different background for their UIControlStateHighlighted . However, I would like more than just a different background image: I would like the button to grow to a larger size when it is first touched. This behavior should look a little like what happens when one presses a letter on the keyboard.

I have tried to change its size in the touchesBegan of the UIPanGestureRecognizer object, but it does not respond when first touched: only when the user starts dragging.

Thank you in advance for your help

Move Me is a sample project provided by Apple which demonstrates how to track an object with gestures and touches, and also has code which changes the size of the object. It is done with a UIView, but the code should be easily portable to a UIButton. Hope that helps!

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