简体   繁体   中英

How to create a draggable NSButton in Swift?

I need help finding the starting point: I want to programmatically create a NSButton as a draggable object in Swift. Do I need to subclass NSButton? Do I need a drag handler? There are a few tutorials on this topic, but they're all for iOS and I'm not safe enough to translate that to OS X. Any help would be appreciated.

Simple, make a subclass of your button which you want to be draggable . something like this @interface CustomButtonSpecial : UIButton . (you got my meaning, you can take the equivalent in swift ie UIGestureRecognizerDelegate.

and then use UILongPressGestureRecognizer , add it to your custom button and implement your logic then, what you want this custom buttom to do.

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