UIBarButtonItem+BlocksKit.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // UIBarButtonItem+BlocksKit.h
  3. // BlocksKit
  4. //
  5. #import <UIKit/UIKit.h>
  6. /** Block event initialization for UIBarButtonItem.
  7. This set of extensions has near-drop-in replacements
  8. for the standard set of UIBarButton item initializations,
  9. using a block handler instead of a target/selector.
  10. Includes code by the following:
  11. - [Kevin O'Neill](https://github.com/kevinoneill)
  12. - [Zach Waldowski](https://github.com/zwaldowski)
  13. @warning UIBarButtonItem is only available on a platform with UIKit.
  14. */
  15. @interface UIBarButtonItem (BlocksKit)
  16. /** Creates and returns a configured item containing the specified system item.
  17. @return Newly initialized item with the specified properties.
  18. @param systemItem The system item to use as the item representation. One of the constants defined in UIBarButtonSystemItem.
  19. @param action The block that gets fired on the button press.
  20. */
  21. - (id)bk_initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem handler:(void (^)(id sender))action NS_REPLACES_RECEIVER;
  22. /** Creates and returns a configured item using the specified image and style.
  23. @return Newly initialized item with the specified properties.
  24. @param image The item’s image. If nil an image is not displayed.
  25. If this image is too large to fit on the bar, it is scaled to fit
  26. The size of a toolbar and navigation bar image is 20 x 20 points.
  27. @param style The style of the item. One of the constants defined in UIBarButtonItemStyle.
  28. @param action The block that gets fired on the button press.
  29. */
  30. - (id)bk_initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style handler:(void (^)(id sender))action NS_REPLACES_RECEIVER;
  31. /** Creates and returns a configured item using the specified image and style.
  32. @return Newly initialized item with the specified properties.
  33. @param image The item’s image. If nil an image is not displayed.
  34. @param landscapeImagePhone The image to be used for the item in landscape bars in the UIUserInterfaceIdiomPhone idiom.
  35. @param style The style of the item. One of the constants defined in UIBarButtonItemStyle.
  36. @param action The block that gets fired on the button press.
  37. */
  38. - (id)bk_initWithImage:(UIImage *)image landscapeImagePhone:(UIImage *)landscapeImagePhone style:(UIBarButtonItemStyle)style handler:(void (^)(id sender))action NS_REPLACES_RECEIVER NS_AVAILABLE_IOS(5_0);
  39. /** Creates and returns a configured item using the specified text and style.
  40. @return Newly initialized item with the specified properties.
  41. @param title The text displayed on the button item.
  42. @param style The style of the item. One of the constants defined in UIBarButtonItemStyle.
  43. @param action The block that gets fired on the button press.
  44. */
  45. - (id)bk_initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style handler:(void (^)(id sender))action NS_REPLACES_RECEIVER;
  46. @end