MGSwipeButton.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * MGSwipeTableCell is licensed under MIT license. See LICENSE.md file for more information.
  3. * Copyright (c) 2016 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 * _Nonnull cell);
  18. @property (nonatomic, strong, nullable) 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. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title backgroundColor:(nullable UIColor *) color;
  25. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title backgroundColor:(nullable UIColor *) color padding:(NSInteger) padding;
  26. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title backgroundColor:(nullable UIColor *) color insets:(UIEdgeInsets) insets;
  27. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title backgroundColor:(nullable UIColor *) color callback:(nullable MGSwipeButtonCallback) callback;
  28. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title backgroundColor:(nullable UIColor *) color padding:(NSInteger) padding callback:(nullable MGSwipeButtonCallback) callback;
  29. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title backgroundColor:(nullable UIColor *) color insets:(UIEdgeInsets) insets callback:(nullable MGSwipeButtonCallback) callback;
  30. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title icon:(nullable UIImage*) icon backgroundColor:(nullable UIColor *) color;
  31. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title icon:(nullable UIImage*) icon backgroundColor:(nullable UIColor *) color padding:(NSInteger) padding;
  32. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title icon:(nullable UIImage*) icon backgroundColor:(nullable UIColor *) color insets:(UIEdgeInsets) insets;
  33. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title icon:(nullable UIImage*) icon backgroundColor:(nullable UIColor *) color callback:(nullable MGSwipeButtonCallback) callback;
  34. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title icon:(nullable UIImage*) icon backgroundColor:(nullable UIColor *) color padding:(NSInteger) padding callback:(nullable MGSwipeButtonCallback) callback;
  35. +(nonnull instancetype) buttonWithTitle:(nonnull NSString *) title icon:(nullable UIImage*) icon backgroundColor:(nullable UIColor *) color insets:(UIEdgeInsets) insets callback:(nullable MGSwipeButtonCallback) callback;
  36. -(void) setPadding:(CGFloat) padding;
  37. -(void) setEdgeInsets:(UIEdgeInsets)insets;
  38. -(void) centerIconOverText;
  39. -(void) centerIconOverTextWithSpacing: (CGFloat) spacing;
  40. -(void) iconTintColor:(nullable UIColor *)tintColor;
  41. @end