YCMenuView.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // YCMenuView.h
  3. // Demo
  4. //
  5. // Created by 蔡亚超 on 2018/8/28.
  6. // Copyright © 2018年 WellsCai. All rights reserved.
  7. // github地址:https://github.com/WellsYC/YCMenuView
  8. // 简书地址:https://www.jianshu.com/u/f853cbc68abb
  9. #import <UIKit/UIKit.h>
  10. @class YCMenuAction;
  11. @interface YCMenuView : UIView
  12. //默认倒角 default = 5.0
  13. @property (nonatomic,assign) CGFloat cornerRaius;
  14. //设置分割线颜色 default = 灰色
  15. @property (nonatomic,strong) UIColor *separatorColor;
  16. //设置菜单颜色 default = 白色(也可以通过BackgroundColor设置)
  17. @property (nonatomic,strong) UIColor *menuColor;
  18. //设置菜单单元格高度 default = 44
  19. @property (nonatomic,assign) CGFloat menuCellHeight;
  20. //最大显示数量 default = 5
  21. @property (nonatomic,assign) NSInteger maxDisplayCount;
  22. //是否显示阴影 default = YES(默认设置,也可以自己通过layer属性设置)
  23. @property (nonatomic,assign,getter = isShadowShowing)BOOL isShowShadow;
  24. //选择菜单选项后消失 default = YES
  25. @property (nonatomic,assign) BOOL dismissOnselected;
  26. //点击菜单外消失 default = YES
  27. @property (nonatomic,assign) BOOL dismissOnTouchOutside;
  28. //设置字体大小 default = 15
  29. @property (nonatomic,assign) UIFont *textFont;
  30. //设置字体颜色 default = 黑色
  31. @property (nonatomic,strong) UIColor *textColor;
  32. //设置偏移距离 default = 0(与触摸点在Y轴上的偏移)
  33. @property (nonatomic,assign) CGFloat offset;
  34. //关闭回调
  35. @property (nonatomic, copy) void(^dissmisBlock)(void);
  36. // 从关联点创建
  37. + (instancetype)menuWithActions:(NSArray<YCMenuAction *> *)actions width:(CGFloat)width atPoint:(CGPoint)point;
  38. // 从关联视图创建(可以是UIView和UIBarButtonItem)
  39. + (instancetype)menuWithActions:(NSArray<YCMenuAction *> *)actions width:(CGFloat)width relyonView:(id)view;
  40. - (void)show;
  41. - (instancetype)init NS_UNAVAILABLE;
  42. + (instancetype)new NS_UNAVAILABLE;
  43. @end
  44. @interface YCMenuAction : NSObject
  45. @property (nonatomic, readonly) NSString *title;
  46. @property (nonatomic, readonly) UIImage *image;
  47. //@property (nonatomic, weak) QKTaskListModelActions *actionBean;
  48. @property (nonatomic,copy, readonly) void (^handler)(YCMenuAction *action);
  49. + (instancetype)actionWithTitle:(NSString *)title image:(UIImage *)image handler:(void (^)(YCMenuAction *action))handler;
  50. - (instancetype)init NS_UNAVAILABLE;
  51. + (instancetype)new NS_UNAVAILABLE;
  52. @end