YBIBImageLayout.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // YBIBImageLayout.h
  3. // YBImageBrowserDemo
  4. //
  5. // Created by 波儿菜 on 2019/6/12.
  6. // Copyright © 2019 波儿菜. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @protocol YBIBImageLayout <NSObject>
  11. @required
  12. /**
  13. 计算图片展示的位置
  14. @param containerSize 容器大小
  15. @param imageSize 图片大小 (逻辑像素)
  16. @param orientation 图片浏览器的方向
  17. @return 图片展示的位置 (frame)
  18. */
  19. - (CGRect)yb_imageViewFrameWithContainerSize:(CGSize)containerSize imageSize:(CGSize)imageSize orientation:(UIDeviceOrientation)orientation;
  20. /**
  21. 计算最大缩放比例
  22. @param containerSize 容器大小
  23. @param imageSize 图片大小 (逻辑像素)
  24. @param orientation 图片浏览器的方向
  25. @return 最大缩放比例
  26. */
  27. - (CGFloat)yb_maximumZoomScaleWithContainerSize:(CGSize)containerSize imageSize:(CGSize)imageSize orientation:(UIDeviceOrientation)orientation;
  28. @end
  29. typedef NS_ENUM(NSUInteger, YBIBImageFillType) {
  30. /// 宽度优先填充满
  31. YBIBImageFillTypeFullWidth,
  32. /// 完整显示
  33. YBIBImageFillTypeCompletely
  34. };
  35. @interface YBIBImageLayout : NSObject <YBIBImageLayout>
  36. /// 纵向的填充方式,默认 YBIBImageFillTypeCompletely
  37. @property (nonatomic, assign) YBIBImageFillType verticalFillType;
  38. /// 横向的填充方式,默认 YBIBImageFillTypeFullWidth
  39. @property (nonatomic, assign) YBIBImageFillType horizontalFillType;
  40. /// 最大缩放比例 (必须大于 1 才有效,若不指定内部会自动计算)
  41. @property (nonatomic, assign) CGFloat maxZoomScale;
  42. /// 自动计算严格缩放比例后,再乘以这个值作为最终缩放比例,默认 1.5
  43. @property (nonatomic, assign) CGFloat zoomScaleSurplus;
  44. @end
  45. NS_ASSUME_NONNULL_END