YYTextSelectionView.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // YYTextSelectionView.h
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 15/2/25.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import <UIKit/UIKit.h>
  12. #if __has_include(<YYKit/YYKit.h>)
  13. #import <YYKit/YYTextAttribute.h>
  14. #import <YYKit/YYTextInput.h>
  15. #else
  16. #import "YYTextAttribute.h"
  17. #import "YYTextInput.h"
  18. #endif
  19. NS_ASSUME_NONNULL_BEGIN
  20. /**
  21. A single dot view. The frame should be foursquare.
  22. Change the background color for display.
  23. @discussion Typically, you should not use this class directly.
  24. */
  25. @interface YYSelectionGrabberDot : UIView
  26. /// Dont't access this property. It was used by `YYTextEffectWindow`.
  27. @property (nonatomic, strong) UIView *mirror;
  28. @end
  29. /**
  30. A grabber (stick with a dot).
  31. @discussion Typically, you should not use this class directly.
  32. */
  33. @interface YYSelectionGrabber : UIView
  34. @property (nonatomic, readonly) YYSelectionGrabberDot *dot; ///< the dot view
  35. @property (nonatomic) YYTextDirection dotDirection; ///< don't support composite direction
  36. @property (nullable, nonatomic, strong) UIColor *color; ///< tint color, default is nil
  37. @end
  38. /**
  39. The selection view for text edit and select.
  40. @discussion Typically, you should not use this class directly.
  41. */
  42. @interface YYTextSelectionView : UIView
  43. @property (nullable, nonatomic, weak) UIView *hostView; ///< the holder view
  44. @property (nullable, nonatomic, strong) UIColor *color; ///< the tint color
  45. @property (nonatomic, getter = isCaretBlinks) BOOL caretBlinks; ///< whether the caret is blinks
  46. @property (nonatomic, getter = isCaretVisible) BOOL caretVisible; ///< whether the caret is visible
  47. @property (nonatomic, getter = isVerticalForm) BOOL verticalForm; ///< weather the text view is vertical form
  48. @property (nonatomic) CGRect caretRect; ///< caret rect (width==0 or height==0)
  49. @property (nullable, nonatomic, copy) NSArray<YYTextSelectionRect *> *selectionRects; ///< default is nil
  50. @property (nonatomic, readonly) UIView *caretView;
  51. @property (nonatomic, readonly) YYSelectionGrabber *startGrabber;
  52. @property (nonatomic, readonly) YYSelectionGrabber *endGrabber;
  53. - (BOOL)isGrabberContainsPoint:(CGPoint)point;
  54. - (BOOL)isStartGrabberContainsPoint:(CGPoint)point;
  55. - (BOOL)isEndGrabberContainsPoint:(CGPoint)point;
  56. - (BOOL)isCaretContainsPoint:(CGPoint)point;
  57. - (BOOL)isSelectionRectsContainsPoint:(CGPoint)point;
  58. @end
  59. NS_ASSUME_NONNULL_END