NewUIScrollViewOffset.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // NewUIScrollViewOffset.m
  3. // MingMen
  4. //
  5. // Created by 罗云飞 on 2017/3/9.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "NewUIScrollViewOffset.h"
  9. @implementation UIScrollView (ScrollViewOffset)
  10. - (CGFloat)offsetX {
  11. return self.contentOffset.x;
  12. }
  13. - (void)setOffsetX:(CGFloat)offsetX {
  14. self.contentOffset = CGPointMake(offsetX, self.contentOffset.y);
  15. }
  16. - (CGFloat)offsetY {
  17. return self.contentOffset.y;
  18. }
  19. - (void)setOffsetY:(CGFloat)offsetY {
  20. self.contentOffset = CGPointMake(self.contentOffset.x, offsetY);
  21. }
  22. - (CGFloat)contentWidth {
  23. return self.contentSize.width;
  24. }
  25. - (void)setContentWidth:(CGFloat)width {
  26. CGSize contentSize = self.contentSize;
  27. contentSize.width = width;
  28. self.contentSize = CGSizeMake(width, self.contentSize.height);
  29. }
  30. - (CGFloat)contentHeight {
  31. return self.contentSize.height;
  32. }
  33. - (void)setContentHeight:(CGFloat)height {
  34. CGSize contentSize = self.contentSize;
  35. contentSize.height = height;
  36. self.contentSize = CGSizeMake(self.contentSize.height, height);
  37. }
  38. @end