MGSwipeButton.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * MGSwipeTableCell is licensed under MIT license. See LICENSE.md file for more information.
  3. * Copyright (c) 2014 Imanol Fernandez @MortimerGoro
  4. */
  5. #import <UIKit/UIKit.h>
  6. @class MGSwipeTableCell;
  7. /**
  8. * This is a convenience class to create MGSwipeTableCell buttons
  9. * Using this class is optional because MGSwipeTableCell is button agnostic and can use any UIView for that purpose
  10. * Anyway, it's recommended that you use this class because is totally tested and easy to use ;)
  11. */
  12. @interface MGSwipeButton : UIButton
  13. /**
  14. * Convenience block callback for developers lazy to implement the MGSwipeTableCellDelegate.
  15. * @return Return YES to autohide the swipe view
  16. */
  17. typedef BOOL(^MGSwipeButtonCallback)(MGSwipeTableCell * sender);
  18. @property (nonatomic, strong) MGSwipeButtonCallback callback;
  19. /** A width for the expanded buttons. Defaults to 0, which means sizeToFit will be called. */
  20. @property (nonatomic, assign) CGFloat buttonWidth;
  21. /**
  22. * Convenience static constructors
  23. */
  24. +(instancetype) buttonWithTitle:(NSString *) title backgroundColor:(UIColor *) color;
  25. +(instancetype) buttonWithTitle:(NSString *) title backgroundColor:(UIColor *) color padding:(NSInteger) padding;
  26. +(instancetype) buttonWithTitle:(NSString *) title backgroundColor:(UIColor *) color insets:(UIEdgeInsets) insets;
  27. +(instancetype) buttonWithTitle:(NSString *) title backgroundColor:(UIColor *) color callback:(MGSwipeButtonCallback) callback;
  28. +(instancetype) buttonWithTitle:(NSString *) title backgroundColor:(UIColor *) color padding:(NSInteger) padding callback:(MGSwipeButtonCallback) callback;
  29. +(instancetype) buttonWithTitle:(NSString *) title backgroundColor:(UIColor *) color insets:(UIEdgeInsets) insets callback:(MGSwipeButtonCallback) callback;
  30. +(instancetype) buttonWithTitle:(NSString *) title icon:(UIImage*) icon backgroundColor:(UIColor *) color;
  31. +(instancetype) buttonWithTitle:(NSString *) title icon:(UIImage*) icon backgroundColor:(UIColor *) color padding:(NSInteger) padding;
  32. +(instancetype) buttonWithTitle:(NSString *) title icon:(UIImage*) icon backgroundColor:(UIColor *) color insets:(UIEdgeInsets) insets;
  33. +(instancetype) buttonWithTitle:(NSString *) title icon:(UIImage*) icon backgroundColor:(UIColor *) color callback:(MGSwipeButtonCallback) callback;
  34. +(instancetype) buttonWithTitle:(NSString *) title icon:(UIImage*) icon backgroundColor:(UIColor *) color padding:(NSInteger) padding callback:(MGSwipeButtonCallback) callback;
  35. +(instancetype) buttonWithTitle:(NSString *) title icon:(UIImage*) icon backgroundColor:(UIColor *) color insets:(UIEdgeInsets) insets callback:(MGSwipeButtonCallback) callback;
  36. -(void) setPadding:(CGFloat) padding;
  37. -(void) setEdgeInsets:(UIEdgeInsets)insets;
  38. -(void) centerIconOverText;
  39. @end