UIControl+YYAdd.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // UIControl+YYAdd.h
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 13/4/5.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import <UIKit/UIKit.h>
  12. NS_ASSUME_NONNULL_BEGIN
  13. /**
  14. Provides extensions for `UIControl`.
  15. */
  16. @interface UIControl (YYAdd)
  17. /**
  18. Removes all targets and actions for a particular event (or events)
  19. from an internal dispatch table.
  20. */
  21. - (void)removeAllTargets;
  22. /**
  23. Adds or replaces a target and action for a particular event (or events)
  24. to an internal dispatch table.
  25. @param target The target object—that is, the object to which the
  26. action message is sent. If this is nil, the responder
  27. chain is searched for an object willing to respond to the
  28. action message.
  29. @param action A selector identifying an action message. It cannot be NULL.
  30. @param controlEvents A bitmask specifying the control events for which the
  31. action message is sent.
  32. */
  33. - (void)setTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
  34. /**
  35. Adds a block for a particular event (or events) to an internal dispatch table.
  36. It will cause a strong reference to @a block.
  37. @param block The block which is invoked then the action message is
  38. sent (cannot be nil). The block is retained.
  39. @param controlEvents A bitmask specifying the control events for which the
  40. action message is sent.
  41. */
  42. - (void)addBlockForControlEvents:(UIControlEvents)controlEvents block:(void (^)(id sender))block;
  43. /**
  44. Adds or replaces a block for a particular event (or events) to an internal
  45. dispatch table. It will cause a strong reference to @a block.
  46. @param block The block which is invoked then the action message is
  47. sent (cannot be nil). The block is retained.
  48. @param controlEvents A bitmask specifying the control events for which the
  49. action message is sent.
  50. */
  51. - (void)setBlockForControlEvents:(UIControlEvents)controlEvents block:(void (^)(id sender))block;
  52. /**
  53. Removes all blocks for a particular event (or events) from an internal
  54. dispatch table.
  55. @param controlEvents A bitmask specifying the control events for which the
  56. action message is sent.
  57. */
  58. - (void)removeAllBlocksForControlEvents:(UIControlEvents)controlEvents;
  59. @end
  60. NS_ASSUME_NONNULL_END