BBABubbleGuideView.h 6.11 KB
//
//  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