| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- //
- // ChatPopoverView.h
- // AIIM
- //
- // Created by qitewei on 2025/5/7.
- //
- #import <UIKit/UIKit.h>
- NS_ASSUME_NONNULL_BEGIN
- typedef NS_ENUM(NSInteger, PopoverViewArrowDirection) {
- PopoverViewArrowDirectionUp, // 箭头向上,弹窗在源视图下方
- PopoverViewArrowDirectionDown, // 箭头向下,弹窗在源视图上方
- PopoverViewArrowDirectionAuto, // 自动根据空间选择方向
- PopoverViewArrowDirectionNone // 无箭头
- };
- typedef NS_ENUM(NSInteger, PopoverViewPosition) {
- PopoverViewPositionTop, // 弹窗在源视图顶部
- PopoverViewPositionBottom, // 弹窗在源视图底部
- PopoverViewPositionAuto // 自动选择位置
- };
- @interface ChatPopoverView : UIView
- /**
- 初始化弹窗
-
- @param contentView 弹窗内容视图
- @param sourceView 源视图(弹窗指向的视图)
- @return 弹窗实例
- */
- - (instancetype)initWithContentView:(UIView *)contentView sourceView:(UIView *)sourceView;
- /**
- 显示弹窗
- */
- - (void)show;
- /**
- 隐藏弹窗
- */
- - (void)dismiss;
- /**
- 是否允许点击外部区域隐藏弹窗,默认为YES
- */
- @property (nonatomic, assign) BOOL shouldDismissOnOutsideTap;
- /**
- 弹窗位置,默认为PopoverViewPositionAuto
- */
- @property (nonatomic, assign) PopoverViewPosition preferredPosition;
- /**
- 箭头方向,默认为PopoverViewArrowDirectionAuto
- 如果设置了preferredPosition,此属性会被忽略
- */
- @property (nonatomic, assign) PopoverViewArrowDirection arrowDirection;
- /**
- 弹窗与源视图的间距,默认为0
- */
- @property (nonatomic, assign) CGFloat sourceViewGap;
- /**
- 是否显示箭头,默认为YES
- */
- @property (nonatomic, assign) BOOL showArrow;
- /**
- 弹窗背景色,默认为白色
- */
- @property (nonatomic, strong) UIColor *popoverBackgroundColor;
- /**
- 边框颜色,默认为lightGrayColor
- */
- @property (nonatomic, strong) UIColor *borderColor;
- /**
- 边框宽度,默认为1.0
- */
- @property (nonatomic, assign) CGFloat borderWidth;
- /**
- 圆角半径,默认为5.0
- */
- @property (nonatomic, assign) CGFloat cornerRadius;
- /**
- 箭头高度,默认为8.0
- */
- @property (nonatomic, assign) CGFloat arrowHeight;
- /**
- 弹窗与屏幕边缘的最小间距,默认为10.0
- */
- @property (nonatomic, assign) CGFloat popoverMargin;
- @end
- NS_ASSUME_NONNULL_END
|