PopupView.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // PopupView.h
  3. // AIIM
  4. //
  5. // Created by qitewei on 2025/5/29.
  6. //
  7. #import <UIKit/UIKit.h>
  8. NS_ASSUME_NONNULL_BEGIN
  9. typedef NS_ENUM(NSInteger, PopupPosition) {
  10. PopupPositionTop,
  11. PopupPositionCenter,
  12. PopupPositionBottom
  13. };
  14. typedef NS_ENUM(NSInteger, PopupAnimationType) {
  15. PopupAnimationTypeFromBottom, // 自下往上
  16. PopupAnimationTypeFromTop, // 自上往下
  17. PopupAnimationTypeFade // 淡入淡出
  18. };
  19. typedef NS_ENUM(NSInteger, PopupContainerType) {
  20. PopupContainerTypeView, // 添加到当前view
  21. PopupContainerTypeWindow // 添加到window
  22. };
  23. @interface PopupView : UIView
  24. /// 自定义视图
  25. @property (nonatomic, strong) UIView *customView;
  26. /// 弹窗位置 (默认居中)
  27. @property (nonatomic, assign) PopupPosition position;
  28. /// 动画类型 (默认自下往上)
  29. @property (nonatomic, assign) PopupAnimationType animationType;
  30. /// 点击外部是否关闭 (默认YES)
  31. @property (nonatomic, assign) BOOL dismissOnBackgroundTap;
  32. /// 上下偏移量 (默认0)
  33. @property (nonatomic, assign) CGFloat offset;
  34. /// 显示层级 (默认View)
  35. @property (nonatomic, assign) PopupContainerType containerType;
  36. /// 背景颜色 (默认半透明黑)
  37. @property (nonatomic, strong) UIColor *backgroundColor;
  38. /// 弹窗消失完成回调
  39. @property (nonatomic, copy) void (^dismissCompletion)(void);
  40. /// 显示弹窗
  41. /// @param view 父视图,如果containerType为Window则可为nil
  42. - (void)showInView:(UIView *)view;
  43. /// 隐藏弹窗
  44. - (void)dismiss;
  45. /// 弹窗显示状态
  46. @property (nonatomic, readonly, getter=isShowing) BOOL showing;
  47. @end
  48. NS_ASSUME_NONNULL_END