123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- //
- // YBPopupMenu.h
- // YBPopupMenu
- //
- // Created by lyb on 2017/5/10.
- // Copyright © 2017年 lyb. All rights reserved.
- //
- #import <UIKit/UIKit.h>
- #import "YBPopupMenuPath.h"
- #import "YBPopupMenuDeviceOrientationManager.h"
- #import "YBPopupMenuAnimationManager.h"
- // 过期提醒
- #define YBDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)
- typedef NS_ENUM(NSInteger , YBPopupMenuType) {
- YBPopupMenuTypeDefault = 0,
- YBPopupMenuTypeDark
- };
- /**
- 箭头方向优先级
- 当控件超出屏幕时会自动调整成反方向
- */
- typedef NS_ENUM(NSInteger , YBPopupMenuPriorityDirection) {
- YBPopupMenuPriorityDirectionTop = 0, //Default
- YBPopupMenuPriorityDirectionBottom,
- YBPopupMenuPriorityDirectionLeft,
- YBPopupMenuPriorityDirectionRight,
- YBPopupMenuPriorityDirectionNone //不自动调整
- };
- @class YBPopupMenu;
- @protocol YBPopupMenuDelegate <NSObject>
- @optional
- - (void)ybPopupMenuBeganDismiss:(YBPopupMenu *)ybPopupMenu;
- - (void)ybPopupMenuDidDismiss:(YBPopupMenu *)ybPopupMenu;
- - (void)ybPopupMenuBeganShow:(YBPopupMenu *)ybPopupMenu;
- - (void)ybPopupMenuDidShow:(YBPopupMenu *)ybPopupMenu;
- /**
- 点击事件回调
- */
- - (void)ybPopupMenu:(YBPopupMenu *)ybPopupMenu didSelectedAtIndex:(NSInteger)index;
- /**
- 自定义cell
-
- 可以自定义cell,设置后会忽略 fontSize textColor backColor type 属性
- cell 的高度是根据 itemHeight 的,直接设置无效
- 建议cell 背景色设置为透明色,不然切的圆角显示不出来
- */
- - (UITableViewCell *)ybPopupMenu:(YBPopupMenu *)ybPopupMenu cellForRowAtIndex:(NSInteger)index;
- /// 自定义cell高度
- - (CGFloat)ybPopupMenu:(YBPopupMenu *)ybPopupMenu heightForRowAtIndex:(NSInteger)index;
- @end
- @interface YBPopupMenu : UIView
- //选中变色
- @property(nonatomic,assign)BOOL selectTextColor;
- //文字居中
- @property(nonatomic,assign)BOOL isCenter;
- /**
- 标题数组 只读属性
- */
- @property (nonatomic, strong, readonly) NSArray * titles;
- /**
- 图片数组 只读属性
- */
- @property (nonatomic, strong, readonly) NSArray * images;
- /**
- tableView Default separatorStyle is UITableViewCellSeparatorStyleNone
- */
- @property (nonatomic, strong) UITableView * tableView;
- /**
- 圆角半径 Default is 5.0
- */
- @property (nonatomic, assign) CGFloat cornerRadius;
- /**
- 自定义圆角 Default is UIRectCornerAllCorners
-
- 当自动调整方向时corner会自动转换至镜像方向
- */
- @property (nonatomic, assign) UIRectCorner rectCorner;
- /**
- 是否显示阴影 Default is YES
- */
- @property (nonatomic, assign , getter=isShadowShowing) BOOL isShowShadow;
- /**
- 是否显示灰色覆盖层 Default is YES
- */
- @property (nonatomic, assign) BOOL showMaskView;
- /**
- 选择菜单项后消失 Default is YES
- */
- @property (nonatomic, assign) BOOL dismissOnSelected;
- /**
- 点击菜单外消失 Default is YES
- */
- @property (nonatomic, assign) BOOL dismissOnTouchOutside;
- /**
- 设置字体大小 自定义cell时忽略 Default is 15
- */
- @property (nonatomic, assign) CGFloat fontSize;
- /**
- 设置字体 设置时忽略fontSize Default is nil
- */
- @property (nonatomic, strong) UIFont * font;
- /**
- 设置字体颜色 自定义cell时忽略 Default is [UIColor blackColor]
- */
- @property (nonatomic, strong) UIColor * textColor;
- /**
- 设置偏移距离 (>= 0) Default is 0.0
- */
- @property (nonatomic, assign) CGFloat offset;
- /**
- 边框宽度 Default is 0.0
-
- 设置边框需 > 0
- */
- @property (nonatomic, assign) CGFloat borderWidth;
- /**
- 边框颜色 Default is LightGrayColor
-
- borderWidth <= 0 无效
- */
- @property (nonatomic, strong) UIColor * borderColor;
- /**
- 箭头宽度 Default is 15
- */
- @property (nonatomic, assign) CGFloat arrowWidth;
- /**
- 箭头高度 Default is 10
- */
- @property (nonatomic, assign) CGFloat arrowHeight;
- /**
- 箭头位置 Default is center
-
- 只有箭头优先级是YBPopupMenuPriorityDirectionLeft/YBPopupMenuPriorityDirectionRight/YBPopupMenuPriorityDirectionNone时需要设置
- */
- @property (nonatomic, assign) CGFloat arrowPosition;
- /**
- 箭头方向 Default is YBPopupMenuArrowDirectionTop
- */
- @property (nonatomic, assign) YBPopupMenuArrowDirection arrowDirection;
- /**
- 箭头优先方向 Default is YBPopupMenuPriorityDirectionTop
-
- 当控件超出屏幕时会自动调整箭头位置
- */
- @property (nonatomic, assign) YBPopupMenuPriorityDirection priorityDirection;
- /**
- 可见的最大行数 Default is 5;
- */
- @property (nonatomic, assign) NSInteger maxVisibleCount;
- /**
- menu背景色 自定义cell时忽略 Default is WhiteColor
- */
- @property (nonatomic, strong) UIColor * backColor;
- /**
- item的高度 Default is 44;
- */
- @property (nonatomic, assign) CGFloat itemHeight;
- /**
- popupMenu距离最近的Screen的距离 Default is 10
- */
- @property (nonatomic, assign) CGFloat minSpace;
- /**
- 设置显示模式 自定义cell时忽略 Default is YBPopupMenuTypeDefault
- */
- @property (nonatomic, assign) YBPopupMenuType type;
- /**
- 屏幕旋转管理
- */
- @property (nonatomic, strong) id <YBPopupMenuDeviceOrientationManager> orientationManager;
- /**
- 动画管理
- */
- @property (nonatomic, strong) id <YBPopupMenuAnimationManager> animationManager;
- /**
- 代理
- */
- @property (nonatomic, weak) id <YBPopupMenuDelegate> delegate;
- /**
- 在指定位置弹出
-
- @param point 弹出的位置
- @param titles 标题数组 数组里是NSString/NSAttributedString
- @param icons 图标数组 数组里是NSString/UIImage
- @param itemWidth 菜单宽度
- @param otherSetting 其他设置
- */
- + (YBPopupMenu *)showAtPoint:(CGPoint)point
- titles:(NSArray *)titles
- icons:(NSArray *)icons
- menuWidth:(CGFloat)itemWidth
- otherSettings:(void (^) (YBPopupMenu * popupMenu))otherSetting;
- /**
- 依赖指定view弹出
- @param titles 标题数组 数组里是NSString/NSAttributedString
- @param icons 图标数组 数组里是NSString/UIImage
- @param itemWidth 菜单宽度
- @param otherSetting 其他设置
- */
- + (YBPopupMenu *)showRelyOnView:(UIView *)view
- titles:(NSArray *)titles
- icons:(NSArray *)icons
- menuWidth:(CGFloat)itemWidth
- otherSettings:(void (^) (YBPopupMenu * popupMenu))otherSetting;
- /**
- 隐藏
- */
- - (void)dismiss;
- /**
- 隐藏window上所有的popupMenu
- */
- + (void)dismissAllPopupMenu;
- @end
|