AutoLayoutScrollView.m 786 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // AutoLayoutScrollView.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/11/2.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "AutoLayoutScrollView.h"
  9. @implementation AutoLayoutScrollView
  10. -(void) autoContentSize:(Oritation) type{
  11. CGFloat width = 0;
  12. CGFloat height= 0;
  13. for (UIView* view in self.subviews){
  14. height += view.frame.size.height;
  15. width += view.frame.size.width;
  16. }
  17. switch (type) {
  18. case horizontal:{
  19. self.contentSize = CGSizeMake(width, 0.0f);
  20. }
  21. break;
  22. case vertical:{
  23. self.contentSize = CGSizeMake(0.0f, height);
  24. }break;
  25. default:
  26. break;
  27. }
  28. }
  29. @end