UIView+Layout.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // UIView+Layout.h
  3. // CommonLibrary
  4. //
  5. // Created by Alexi Chen on 2/28/13.
  6. // Copyright (c) 2013 AlexiChen. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. typedef enum : NSUInteger {
  10. TZOscillatoryAnimationToBigger,
  11. TZOscillatoryAnimationToSmaller,
  12. } TZOscillatoryAnimationType;
  13. @interface UIView (Layout)
  14. @property (assign, nonatomic) CGFloat top;
  15. @property (assign, nonatomic) CGFloat bottom;
  16. @property (assign, nonatomic) CGFloat left;
  17. @property (assign, nonatomic) CGFloat right;
  18. @property (assign, nonatomic) CGFloat x;
  19. @property (assign, nonatomic) CGFloat y;
  20. @property (assign, nonatomic) CGPoint origin;
  21. @property (assign, nonatomic) CGFloat centerX;
  22. @property (assign, nonatomic) CGFloat centerY;
  23. @property (assign, nonatomic) CGFloat width;
  24. @property (assign, nonatomic) CGFloat height;
  25. @property (assign, nonatomic) CGSize size;
  26. @property (nonatomic) CGFloat tz_left; ///< Shortcut for frame.origin.x.
  27. @property (nonatomic) CGFloat tz_top; ///< Shortcut for frame.origin.y
  28. @property (nonatomic) CGFloat tz_right; ///< Shortcut for frame.origin.x + frame.size.width
  29. @property (nonatomic) CGFloat tz_bottom; ///< Shortcut for frame.origin.y + frame.size.height
  30. @property (nonatomic) CGFloat tz_width; ///< Shortcut for frame.size.width.
  31. @property (nonatomic) CGFloat tz_height; ///< Shortcut for frame.size.height.
  32. @property (nonatomic) CGFloat tz_centerX; ///< Shortcut for center.x
  33. @property (nonatomic) CGFloat tz_centerY; ///< Shortcut for center.y
  34. @property (nonatomic) CGPoint tz_origin; ///< Shortcut for frame.origin.
  35. @property (nonatomic) CGSize tz_size; ///< Shortcut for frame.size.
  36. + (void)showOscillatoryAnimationWithLayer:(CALayer *)layer type:(TZOscillatoryAnimationType)type;
  37. // 添加子控件
  38. - (void)addOwnViews;
  39. // 配置子控件参数
  40. - (void)configOwnViews;
  41. //- (void)configWith:(NSMutableDictionary *)jsonDic;
  42. // isAutoLayoutr返回YES时,使用此方法进行布局
  43. - (void)autoLayoutSubViews;
  44. // 是否使用自动布局
  45. - (BOOL)isAutoLayout;
  46. /**
  47. 外部通过此功能进行设置,只在布局时使用
  48. @param rect CGRect
  49. */
  50. - (void)setFrameAndLayout:(CGRect)rect;
  51. /**
  52. 对于一些自定义的UIView,在设置Frame后,如需要重新调整局的话
  53. 作为所以控修改其自身内部子控件的入口
  54. 所有的自定义View最好不要从initWithFrams里面进行设置其子View的frame,统一在些处进行设置
  55. */
  56. - (void)relayoutFrameOfSubViews;
  57. - (void)addBottomLine:(CGRect)rect;
  58. - (void)addBottomLine:(UIColor *)color inRect:(CGRect)rect;
  59. @end
  60. @interface UIView (ShakeAnimation)
  61. // 左右shake
  62. - (void)shake;
  63. - (instancetype)init;
  64. @end