财神随手记账

UIView+HPSlideSegmentRect.m 820B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // UIView+HPSlideSegmentRect.m
  3. // HPSlideSegmentView
  4. //
  5. // Created by 何鹏 on 17/6/15.
  6. // Copyright © 2017年 何鹏. All rights reserved.
  7. //
  8. #import "UIView+HPSlideSegmentRect.h"
  9. @implementation UIView (HPSlideSegmentRect)
  10. -(void)setWidth:(CGFloat)width
  11. {
  12. self.bounds=CGRectMake(0, 0, width, self.height);
  13. }
  14. -(void)setHeight:(CGFloat)height
  15. {
  16. self.bounds=CGRectMake(0, 0, self.width, height);
  17. }
  18. -(void)setX:(CGFloat)x
  19. {
  20. self.frame=CGRectMake(x, self.y, self.width, self.height);
  21. }
  22. -(void)setY:(CGFloat)y
  23. {
  24. self.frame=CGRectMake(self.x, y, self.width, self.height);
  25. }
  26. -(CGFloat)x
  27. {
  28. return self.frame.origin.x;
  29. }
  30. -(CGFloat)y
  31. {
  32. return self.frame.origin.y;
  33. }
  34. -(CGFloat)width
  35. {
  36. return self.bounds.size.width;
  37. }
  38. -(CGFloat)height
  39. {
  40. return self.bounds.size.height;
  41. }
  42. @end