XYFloatingDragView.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // XYFloatingDragView.h
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/6/29.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. // 悬浮窗 因为此功能具有延伸性,增加了类型管理,根据不同的类型添加对应的view
  8. #import "BaseView.h"
  9. #import "XYFloatingDragVoiceView.h"
  10. NS_ASSUME_NONNULL_BEGIN
  11. typedef enum : NSUInteger {
  12. XYFloatingDragAutomaticStyleNone, // 默认 无自动吸附边界,停留在最后的可控范围内
  13. XYFloatingDragAutomaticStyleMargin, // 自动吸附在可控范围边界,(只有实现左右边界吸附)
  14. XYFloatingDragAutomaticStyleMarginLeft, // 自动吸附在可控范围左边界
  15. XYFloatingDragAutomaticStyleMarginRight, // 自动吸附在可控范围右边界
  16. } XYFloatingDragAutomaticStyle;
  17. typedef enum : NSUInteger {
  18. XYFloatingDragTypeVoiceChatRoom, // 默认 语音聊天室
  19. XYFloatingDragTypeVideoChatRoom, // 视频聊天室
  20. XYFloatingDragTypeLiveRoom, // 直播
  21. XYFloatingDragType1V1Room, // 1v1视频
  22. } XYFloatingDragType;
  23. @protocol XYFloatingDragViewDelegate <NSObject>
  24. /// 打开悬浮窗
  25. - (void)openFloatingDragWindow;
  26. /// 关闭悬浮窗
  27. - (void)closeFloatingDragWindow;
  28. @end
  29. @interface XYFloatingDragView : BaseView
  30. /// 悬浮按钮的拖拽范围 不设置则默认父view的bounds
  31. @property (nonatomic, readonly, assign) CGRect cagingArea;
  32. /// 停留样式 默认 无吸附边界
  33. @property (nonatomic, readonly, assign) XYFloatingDragAutomaticStyle remainStyle;
  34. /// 内容类型 默认语音
  35. @property (nonatomic, readonly, assign) XYFloatingDragType floatingDataType;
  36. /// 代理
  37. @property (nonatomic, weak) id<XYFloatingDragViewDelegate>delegate;
  38. @property (nonatomic, strong) XYFloatingDragVoiceView *voiceView;
  39. // 根据类型创建悬浮窗 会默认好初始值
  40. + (instancetype)floatingDragViewWithFloatingDragType:(XYFloatingDragType)type;
  41. /// 显示view
  42. - (void)showAnimation:(BOOL)animation;
  43. /// 隐藏view且销毁view
  44. - (void)dismissAnimation:(BOOL)animation;
  45. /// 销毁view
  46. - (void)clear;
  47. /// 设置view信息
  48. - (void)setupViewDataWithModel:(id)model;
  49. @end
  50. NS_ASSUME_NONNULL_END