UIView+EasyFrame.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // UIView+EasyFrame.m
  3. // MLMSegmentPage
  4. //
  5. // Created by my on 2017/2/4.
  6. // Copyright © 2017年 my. All rights reserved.
  7. //
  8. #import "UIView+EasyFrame.h"
  9. @implementation UIView (EasyFrame)
  10. - (void)setX:(CGFloat)x
  11. {
  12. CGRect frame = self.frame;
  13. frame.origin.x = x;
  14. self.frame = frame;
  15. }
  16. - (CGFloat)x
  17. {
  18. return self.frame.origin.x;
  19. }
  20. - (void)setY:(CGFloat)y
  21. {
  22. CGRect frame = self.frame;
  23. frame.origin.y = y;
  24. self.frame = frame;
  25. }
  26. - (CGFloat)y
  27. {
  28. return self.frame.origin.y;
  29. }
  30. - (void)setWidth:(CGFloat)width
  31. {
  32. CGRect frame = self.frame;
  33. frame.size.width = width;
  34. self.frame = frame;
  35. }
  36. - (CGFloat)width
  37. {
  38. return self.frame.size.width;
  39. }
  40. - (void)setHeight:(CGFloat)height
  41. {
  42. CGRect frame = self.frame;
  43. frame.size.height = height;
  44. self.frame = frame;
  45. }
  46. - (CGFloat)height
  47. {
  48. return self.frame.size.height;
  49. }
  50. - (void)setSize:(CGSize)size
  51. {
  52. CGRect frame = self.frame;
  53. frame.size = size;
  54. self.frame = frame;
  55. }
  56. - (CGSize)size
  57. {
  58. return self.frame.size;
  59. }
  60. - (void)setOrigin:(CGPoint)origin
  61. {
  62. CGRect frame = self.frame;
  63. frame.origin = origin;
  64. self.frame = frame;
  65. }
  66. - (CGPoint)origin
  67. {
  68. return self.frame.origin;
  69. }
  70. - (CGFloat)bottomFromSuperView{
  71. return self.superview.height - self.y - self.height;
  72. }
  73. @end