QBPopupMenu.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // QBPopupMenu.h
  3. // QBPopupMenu
  4. //
  5. // Created by Tanaka Katsuma on 2013/11/22.
  6. // Copyright (c) 2013年 Katsuma Tanaka. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "QBPopupMenuItem.h"
  10. @class QBPopupMenu;
  11. @class QBPopupMenuItemView;
  12. @class QBPopupMenuPagenatorView;
  13. @protocol QBPopupMenuDelegate <NSObject>
  14. @optional
  15. - (void)popupMenuWillAppear:(QBPopupMenu *)popupMenu;
  16. - (void)popupMenuDidAppear:(QBPopupMenu *)popupMenu;
  17. - (void)popupMenuWillDisappear:(QBPopupMenu *)popupMenu;
  18. - (void)popupMenuDidDisappear:(QBPopupMenu *)popupMenu;
  19. @end
  20. typedef NS_ENUM(NSUInteger, QBPopupMenuArrowDirection) {
  21. QBPopupMenuArrowDirectionDefault,
  22. QBPopupMenuArrowDirectionUp,
  23. QBPopupMenuArrowDirectionDown,
  24. QBPopupMenuArrowDirectionLeft,
  25. QBPopupMenuArrowDirectionRight
  26. };
  27. @interface QBPopupMenu : UIView
  28. @property (nonatomic, weak) id<QBPopupMenuDelegate> delegate;
  29. @property (nonatomic, assign, getter = isVisible, readonly) BOOL visible;
  30. @property (nonatomic, copy) NSArray *items;
  31. @property (nonatomic, assign) CGFloat height;
  32. @property (nonatomic, assign) CGFloat cornerRadius;
  33. @property (nonatomic, assign) CGFloat arrowSize;
  34. @property (nonatomic, assign) QBPopupMenuArrowDirection arrowDirection;
  35. @property (nonatomic, assign) UIEdgeInsets popupMenuInsets;
  36. @property (nonatomic, assign) CGFloat margin;
  37. @property (nonatomic, strong) UIColor *color;
  38. @property (nonatomic, strong) UIColor *highlightedColor;
  39. + (instancetype)popupMenuWithItems:(NSArray *)items;
  40. - (instancetype)initWithItems:(NSArray *)items;
  41. - (void)showInView:(UIView *)view targetRect:(CGRect)targetRect animated:(BOOL)animated;
  42. - (void)dismissAnimated:(BOOL)animated;
  43. - (void)updateWithTargetRect:(CGRect)targetRect;
  44. // NOTE: When subclassing this class, use these methods to customize the appearance.
  45. + (Class)itemViewClass;
  46. + (Class)pagenatorViewClass;
  47. - (CGMutablePathRef)arrowPathInRect:(CGRect)rect direction:(QBPopupMenuArrowDirection)direction CF_RETURNS_RETAINED;
  48. - (CGMutablePathRef)headPathInRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius CF_RETURNS_RETAINED;
  49. - (CGMutablePathRef)tailPathInRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius CF_RETURNS_RETAINED;
  50. - (CGMutablePathRef)bodyPathInRect:(CGRect)rect CF_RETURNS_RETAINED;
  51. - (void)drawArrowAtPoint:(CGPoint)point arrowSize:(CGFloat)arrowSize arrowDirection:(QBPopupMenuArrowDirection)arrowDirection highlighted:(BOOL)highlighted;
  52. - (void)drawArrowInRect:(CGRect)rect direction:(QBPopupMenuArrowDirection)direction highlighted:(BOOL)highlighted;
  53. - (void)drawHeadInRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius highlighted:(BOOL)highlighted;
  54. - (void)drawTailInRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius highlighted:(BOOL)highlighted;
  55. - (void)drawBodyInRect:(CGRect)rect firstItem:(BOOL)firstItem lastItem:(BOOL)lastItem highlighted:(BOOL)highlighted;
  56. @end