省钱达人

UIView+SGPagingView.m 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // 如遇到问题或有更好方案,请通过以下方式进行联系
  3. // QQ群:429899752
  4. // Email:kingsic@126.com
  5. // GitHub:https://github.com/kingsic/SGPagingView
  6. //
  7. // UIView+SGPagingView.m
  8. // UIView+SGPagingView
  9. //
  10. // Created by kingsic on 15/7/13.
  11. // Copyright © 2015年 kingsic. All rights reserved.
  12. //
  13. #import "UIView+SGPagingView.h"
  14. @implementation UIView (SGPagingView)
  15. - (void)setSG_x:(CGFloat)SG_x {
  16. CGRect frame = self.frame;
  17. frame.origin.x = SG_x;
  18. self.frame = frame;
  19. }
  20. - (CGFloat)SG_x {
  21. return self.frame.origin.x;
  22. }
  23. - (void)setSG_y:(CGFloat)SG_y {
  24. CGRect frame = self.frame;
  25. frame.origin.y = SG_y;
  26. self.frame = frame;
  27. }
  28. - (CGFloat)SG_y {
  29. return self.frame.origin.y;
  30. }
  31. - (void)setSG_width:(CGFloat)SG_width {
  32. CGRect frame = self.frame;
  33. frame.size.width = SG_width;
  34. self.frame = frame;
  35. }
  36. - (CGFloat)SG_width {
  37. return self.frame.size.width;
  38. }
  39. - (void)setSG_height:(CGFloat)SG_height {
  40. CGRect frame = self.frame;
  41. frame.size.height = SG_height;
  42. self.frame = frame;
  43. }
  44. - (CGFloat)SG_height {
  45. return self.frame.size.height;
  46. }
  47. - (CGFloat)SG_centerX {
  48. return self.center.x;
  49. }
  50. - (void)setSG_centerX:(CGFloat)SG_centerX {
  51. CGPoint center = self.center;
  52. center.x = SG_centerX;
  53. self.center = center;
  54. }
  55. - (CGFloat)SG_centerY {
  56. return self.center.y;
  57. }
  58. - (void)setSG_centerY:(CGFloat)SG_centerY {
  59. CGPoint center = self.center;
  60. center.y = SG_centerY;
  61. self.center = center;
  62. }
  63. - (void)setSG_origin:(CGPoint)SG_origin {
  64. CGRect frame = self.frame;
  65. frame.origin = SG_origin;
  66. self.frame = frame;
  67. }
  68. - (CGPoint)SG_origin {
  69. return self.frame.origin;
  70. }
  71. - (void)setSG_size:(CGSize)SG_size {
  72. CGRect frame = self.frame;
  73. frame.size = SG_size;
  74. self.frame = frame;
  75. }
  76. - (CGSize)SG_size {
  77. return self.frame.size;
  78. }
  79. /// 从 XIB 中加载视图
  80. + (instancetype)SG_loadViewFromXib {
  81. return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].lastObject;
  82. }
  83. @end