RSKImageScrollView.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. File: RSKImageScrollView.h
  3. Abstract: Centers image within the scroll view and configures image sizing and display.
  4. Version: 1.5 modified by Ruslan Skorb on 11/26/24.
  5. Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
  6. Inc. ("Apple") in consideration of your agreement to the following
  7. terms, and your use, installation, modification or redistribution of
  8. this Apple software constitutes acceptance of these terms. If you do
  9. not agree with these terms, please do not use, install, modify or
  10. redistribute this Apple software.
  11. In consideration of your agreement to abide by the following terms, and
  12. subject to these terms, Apple grants you a personal, non-exclusive
  13. license, under Apple's copyrights in this original Apple software (the
  14. "Apple Software"), to use, reproduce, modify and redistribute the Apple
  15. Software, with or without modifications, in source and/or binary forms;
  16. provided that if you redistribute the Apple Software in its entirety and
  17. without modifications, you must retain this notice and the following
  18. text and disclaimers in all such redistributions of the Apple Software.
  19. Neither the name, trademarks, service marks or logos of Apple Inc. may
  20. be used to endorse or promote products derived from the Apple Software
  21. without specific prior written permission from Apple. Except as
  22. expressly stated in this notice, no other rights or licenses, express or
  23. implied, are granted by Apple herein, including but not limited to any
  24. patent rights that may be infringed by your derivative works or by other
  25. works in which the Apple Software may be incorporated.
  26. The Apple Software is provided by Apple on an "AS IS" basis. APPLE
  27. MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
  28. THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
  29. FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
  30. OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
  31. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
  32. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  33. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
  35. MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
  36. AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
  37. STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
  38. POSSIBILITY OF SUCH DAMAGE.
  39. Copyright (C) 2012 Apple Inc. All Rights Reserved.
  40. Copyright (C) 2014-present Ruslan Skorb. All Rights Reserved.
  41. */
  42. #import <UIKit/UIKit.h>
  43. NS_HEADER_AUDIT_BEGIN(nullability, sendability)
  44. @protocol RSKImageScrollViewDelegate;
  45. /**
  46. A view that allows the scrolling and zooming of its image.
  47. */
  48. NS_SWIFT_UI_ACTOR
  49. @interface RSKImageScrollView : UIScrollView
  50. /**
  51. A Boolean value that determines whether the image will always fill the available space. Default value is `NO`.
  52. */
  53. @property (nonatomic, assign) BOOL aspectFill;
  54. /**
  55. An image for scrolling and zooming. Default value is `nil`.
  56. */
  57. @property (nonatomic, nullable, strong) UIImage *image;
  58. /**
  59. The delegate of the image scroll view.
  60. @discussion The delegate must adopt the `RSKImageScrollViewDelegate` protocol. The `RSKImageScrollView` class, which doesn’t retain the delegate, invokes each protocol method the delegate implements.
  61. */
  62. @property (nonatomic, nullable, weak) id<RSKImageScrollViewDelegate> imageScrollViewDelegate;
  63. /**
  64. The logical dimensions, in points, of the image. Default value is `CGSizeZero`.
  65. @discussion Can be set to a value different from `image.size`.
  66. */
  67. @property (nonatomic, assign) CGSize imageSize;
  68. /**
  69. The background color of the image view. Default value is `nil`, which results in a transparent color.
  70. @discussion Changes to this property can be animated.
  71. */
  72. @property (nonatomic, nullable, strong) UIColor *imageViewBackgroundColor;
  73. /**
  74. The coordinate space of the image view.
  75. */
  76. @property (nonatomic, readonly) id<UICoordinateSpace> imageViewCoordinateSpace;
  77. /**
  78. The current frame of the image view in the coordinate space of the image scroll view.
  79. */
  80. @property (nonatomic, readonly) CGRect imageViewFrame;
  81. /**
  82. Sets the current scale factor applied to the image and offset from the image’s origin to the initial value.
  83. @param animated `YES` to animate the transition to the new scale and content offset, `NO` to make the transition immediate.
  84. */
  85. - (void)setInitialZoomScaleAndContentOffsetAnimated:(BOOL)animated;
  86. /**
  87. Zooms to a specific location in the image so that it’s visible in the image scroll view.
  88. @param location A point defining a location in the image. The point should be in the coordinate space of the image scroll view.
  89. @param animated `YES` if the scrolling should be animated, `NO` if it should be immediate.
  90. */
  91. - (void)zoomToLocation:(CGPoint)location animated:(BOOL)animated;
  92. @end
  93. NS_HEADER_AUDIT_END(nullability, sendability)