口袋优选

UIView+EasyFrame.m 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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