BBABubbleGuideView.h
6.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//
// BBABubbleGuideView.h
// BBABubbleGuide
//
// Created by Fan,Shuaifei on 2017/5/23.
// Copyright © 2017年 Fan,Shuaifei. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "BBABubbleGuideViewDefine.h"
/**
手百popup气泡组件
默认消失逻辑:7s消失,触摸消失(需要在父view可响应事件区域)
使用流程:
1. 创建实例
BBABubbleGuideView *bubbleView = [[BBABubbleGuideView allco] init];
2. 设置相关属性
bubbleView.property = xxx;
3. 根据实际情况调用相关show方法。
*/
@interface BBABubbleGuideView : UIView
@property (nonatomic, strong) UIFont *textFont; // 气泡显示文字字体,默认14号
@property (nonatomic, strong) UIColor *textColor; // 气泡显示文字颜色,默认白色
@property (nonatomic, strong) UIColor *bubbleBackgroundColor; // 气泡背景色,默认为黑色,透明度0.8
@property (nonatomic, strong) UIColor *maskBackgroundColor; // 蒙版背景色,默认为[UIColor clearColor]
@property (nonatomic, assign) BOOL autoAdjustFrameKeepInScreen; // 是否自动调整frame保证在气泡展示不超出屏幕所在区域,默认值,解决滚动case
@property (nonatomic, assign) BOOL isDismissWhenTouchBubble; // 触摸气泡是否消失, 默认为YES(触摸非超链接区域)
@property (nonatomic, assign) BOOL isDismissWhenClickHyperLink; // 点击超链接气泡是否消失, 默认为YES
@property (nonatomic, assign) BOOL defaultAnimation; // 气泡出现是否有默认动画,默认为YES;
@property (nonatomic, assign, readonly) CGFloat arrowHeight; // 箭头高度,默认为7
@property (nonatomic, assign) CGFloat dismissDuration; // 设置气泡默认消失时间,默认为7.0s, 不需要在一定时间后消失请设置为0.0
@property (nonatomic, assign) CGFloat bubbleEdgeToScreenDistance; // 气泡的边缘距离屏幕边缘的最小距离, 默认为8
@property (nonatomic, assign) UIEdgeInsets edgeInsets; // 文本内容边距调整
@property (nonatomic, assign) CGFloat cornerRadius; // 圆角大小,默认为12
@property (nonatomic, assign) BBABubbleViewArrowDirection arrowDirection; // 气泡箭头方向,默认BBABubbleViewArrowDirectionAuto
@property (nonatomic, assign) BBABubbleMaskViewType maskViewType; // 气泡蒙层类型
@property (nonatomic, assign) BBABubbleDismissType dismissType; // 气泡消失类型
@property (nonatomic, assign) BBABubbleAccessoryType accessoryType; // 附加视图类型 (support-v11.25~)
@property (nonatomic, copy) void (^animationCompletion)(void); // 气泡出现动画执行完回调
@property (nonatomic, copy) void (^bbaBubbleDestroyedCallBack)(void); // 气泡销毁后回调
@property (nonatomic, copy) void (^bbaBubbleClickedCallBack)(void); // 气泡点击回调
#pragma mark - 气泡show,会自动计算气泡大小,箭头位置等
/// 显示气泡,父view为window
/// @param text 显示文字
/// @param point 相对于主window的坐标点
-(void)showBubbleWithText:(NSString *)text
atPoint:(CGPoint )point;
/// 显示气泡,气泡指向hostView,父view为window,箭头位置自动计算,默认view.window
/// @param text 显示文字
/// @param hostView 气泡指向的view
- (void)showBubbleWithText:(NSString *)text
hostView:(UIView *)hostView;
/// 显示气泡,气泡指向hostView,父view为指定window,箭头位置自动计算
/// @param text 显示文字
/// @param hostView 气泡指向的view
/// @param window 指定的window
- (void)showBubbleWithText:(NSString *)text
hostView:(UIView *)hostView
window:(UIWindow *)window;
/// 显示气泡,add在指定父view上,箭头位置自动计算
/// @param text 气泡文字
/// @param view 气泡add到此view上
- (void)showBubbleWithText:(NSString *)text
inView:(UIView *)view;
/// 显示气泡,add在指定父view的指定位置
/// @param text 气泡文字
/// @param view 气泡add到此view上
/// @param point 气泡箭头在view中的点
- (void)showBubbleWithText:(NSString *)text
inView:(UIView *)view
atPoint:(CGPoint)point;
/// 显示气泡,add在指定父view的指定位置,具有超链接文字
/// @param text 气泡文字
/// @param view 气泡add到此view上
/// @param point 气泡箭头在view中的点
/// @param hyperLinkDictionary 存储超链接的字典,key为NSStringFromRange(NSRange range), value为无参数的block(点击range范围文字执行的block)
- (void)showBubbleWithText:(NSString *)text
inView:(UIView *)view
atPoint:(CGPoint)point
hyperLinkDictionary:(NSDictionary *)hyperLinkDictionary;
/// 显示富文本气泡,父view为window
/// @param attributeText 属性字符串
/// @param point 相对于主window的坐标点
-(void)showBubbleWithAttirbuteText:(NSAttributedString *)attributeText
atPoint:(CGPoint )point;
/// 显示富文本气泡,气泡指向hostView,父view为window,箭头位置自动计算
/// @param attributeText 属性字符串
/// @param hostView 气泡指向的view
/// @param window 指定的window(默认keywindow)
- (void)showBubbleWithAttributeText:(NSAttributedString *)attributeText
hostView:(UIView *)hostView
window:(UIWindow *)window;
/// 显示富文本气泡,add在指定父view的指定位置
/// @param attributeText 属性字符串
/// @param view 气泡add到此view上
/// @param point 气泡箭头在view中的点
- (void)showBubbleWithAttirbuteText:(NSAttributedString *)attributeText
inView:(UIView *)view
atPoint:(CGPoint)point;
/// 使用show显示出的气泡,可以通过该函数改变箭头指向的位置
/// @param newArrowStartPoint 新的箭头指向的位置
- (void)changeArrowStartPointTo:(CGPoint)newArrowStartPoint;
#pragma mark - 气泡消失
/// 隐藏气泡,从父view移除
- (void)hideBubble;
@end