UIView+TXFrame.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // UIView+TXFrame.m
  3. // TXSwipeTableViewTest
  4. //
  5. // Created by tingxins on 9/1/16.
  6. // Copyright © 2016 tingxins. All rights reserved.
  7. //
  8. #import "UIView+TXFrame.h"
  9. @implementation UIView (TXFrame)
  10. - (CGFloat)tx_x {
  11. return self.frame.origin.x;
  12. }
  13. - (void)setTx_x:(CGFloat)tx_x {
  14. CGRect frame = self.frame;
  15. frame.origin.x = tx_x;
  16. self.frame = frame;
  17. }
  18. - (CGFloat)tx_y {
  19. return self.frame.origin.y;
  20. }
  21. - (void)setTx_y:(CGFloat)tx_y {
  22. CGRect frame = self.frame;
  23. frame.origin.y = tx_y;
  24. self.frame = frame;
  25. }
  26. - (CGFloat)tx_width {
  27. return self.frame.size.width;
  28. }
  29. - (void)setTx_width:(CGFloat)tx_width {
  30. CGRect frame = self.frame;
  31. frame.size.width = tx_width;
  32. self.frame = frame;
  33. }
  34. - (CGFloat)tx_height {
  35. return self.frame.size.height;
  36. }
  37. - (void)setTx_height:(CGFloat)tx_height {
  38. CGRect frame = self.frame;
  39. frame.size.height = tx_height;
  40. self.frame = frame;
  41. }
  42. - (CGSize)tx_size {
  43. return self.frame.size;
  44. }
  45. - (void)setTx_size:(CGSize)tx_size {
  46. CGRect frame = self.frame;
  47. frame.size = tx_size;
  48. self.frame = frame;
  49. }
  50. - (CGPoint)tx_origin {
  51. return self.frame.origin;
  52. }
  53. - (void)setTx_origin:(CGPoint)tx_origin {
  54. CGRect frame = self.frame;
  55. frame.origin = tx_origin;
  56. self.frame = frame;
  57. }
  58. - (CGPoint)tx_center {
  59. return self.center;
  60. }
  61. - (void)setTx_center:(CGPoint)tx_center {
  62. self.center = tx_center;
  63. }
  64. - (CGFloat)tx_centerX {
  65. return self.center.x;
  66. }
  67. - (void)setTx_centerX:(CGFloat)tx_centerX {
  68. CGPoint center = self.center;
  69. center.x = tx_centerX;
  70. self.center = center;
  71. }
  72. - (CGFloat)tx_centerY {
  73. return self.center.y;
  74. }
  75. - (void)setTx_centerY:(CGFloat)tx_centerY {
  76. CGPoint center = self.center;
  77. center.y = tx_centerY;
  78. self.center = center;
  79. }
  80. - (CGFloat)tx_bottom {
  81. return CGRectGetMaxY(self.frame);
  82. }
  83. - (void)setTx_bottom:(CGFloat)tx_bottom {
  84. CGRect frame = self.frame;
  85. frame.origin.y = tx_bottom - frame.size.height;
  86. self.frame = frame;
  87. }
  88. @end