自定义PopView

       本次分享的是自定义的PopView,功能不难,但是经常用到,每次都根据不同的需求写一个的话很费时,所以简单地封装了一个PopView,效果图如下:


该demo可适配常用的一些参数:

// 距离上下左右的间距
@property(nonatomic, assign) UIEdgeInsets containerEdgeInsets;

// 四角的弧度的半径
@property(nonatomic, assign) CGFloat borderRadius;

// 线宽
@property(nonatomic, assign) CGFloat lineWidth;

// 顶点三角形的上角度(使用弧度制)
@property(nonatomic, assign) CGFloat triangleTopAngle;

// 顶点三角形的高度
@property(nonatomic, assign) CGFloat triangleHeight;

// 定点是否是尖角
@property(nonatomic, assign) BOOL isVertexTip;

// 三角形是否指向上方
@property(nonatomic, assign) BOOL isTriangleUp;

// 是否需要阴影
@property(nonatomic, assign) BOOL isNeedShadow;

// 阴影的偏移量
@property(nonatomic, assign) CGSize shadowOffset;

// 阴影的颜色
@property(nonatomic, strong) UIColor *shadowColor;

// 阴影透明度
@property(nonatomic, assign) CGFloat shadowOpacity;

// 设置顶部三角形的偏移距离,默认是0,表示不偏移
@property(nonatomic, assign) CGFloat triangleDeviationLength;

// popView中间插入的视图
@property(nonatomic, strong) ArtPopBaseInnerView *innerView;

// popView中间插入视图与containerView间距
@property(nonatomic, assign) UIEdgeInsets innerViewInsets;

使用:

可添加到指定PopView包含的视图,以及将PopView添加到指定视图的指定位置或者指定的坐标位置。

将自定义的视图套上PopView,添加到指定的视图中心
+ (void)showPopWithInnerView:(ArtPopBaseInnerView *)innerView On:(UIView *)onView;

将自定义的视图套上PopView,添加到指定的视图中心,并且做简单的偏移
+ (void)showPopWithInnerView:(ArtPopBaseInnerView *)innerView On:(UIView *)onView offset:(CGSize)offset;

将自定义的视图套上PopView,添加到指定的视图中心,并且自定义一些参数配置
+ (void)showPopWithInnerView:(ArtPopBaseInnerView *)innerView On:(UIView *)onView config:(ConfigBlock_Nullable) config;

将自定义的视图套上PopView,添加到指定的视图中心,并且做简单的偏移以及自定义一些参数配置
+ (void)showPopWithInnerView:(ArtPopBaseInnerView *)innerView On:(UIView *)onView offset:(CGSize)offset config:(ConfigBlock_Nullable) config;

将自定义的视图套上PopView,添加到指定的位置,并且做简单的偏移以及自定义一些参数配置
+ (void)showPopWithInnerView:(ArtPopBaseInnerView *)innerView OnPoint:(CGPoint)onPointoffset:(CGSize)offset config:(ConfigBlock) config;

+ (void)hidePopView;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。