UIView+ext.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. Erica Sadun, http://ericasadun.com
  3. iPhone Developer's Cookbook, 3.0 Edition
  4. BSD License, Use at your own risk
  5. */
  6. #import <UIKit/UIKit.h>
  7. CGPoint CGRectGetCenter(CGRect rect);
  8. CGRect CGRectMoveToCenter(CGRect rect, CGPoint center);
  9. @interface UIView (ViewFrameGeometry)
  10. //@property CGPoint origin;
  11. @property CGSize size;
  12. @property (readonly) CGPoint bottomLeft;
  13. @property (readonly) CGPoint bottomRight;
  14. @property (readonly) CGPoint topRight;
  15. @property CGFloat height;
  16. @property CGFloat width;
  17. @property CGFloat top;
  18. @property CGFloat left;
  19. @property CGFloat bottom;
  20. @property CGFloat right;
  21. @property CGFloat x;
  22. @property CGFloat y;
  23. @property CGFloat centerX;
  24. @property CGFloat centerY;
  25. - (void) moveBy: (CGPoint) delta;
  26. - (void) scaleBy: (CGFloat) scaleFactor;
  27. - (void) fitInSize: (CGSize) aSize;
  28. - (void) testFrame;
  29. - (void)setCornerFrame;
  30. - (void)setCornerRadius:(CGFloat)radius;
  31. - (void)setRoundCorner:(UIRectCorner)corner radius:(CGFloat)radius;
  32. //设置单独的边框
  33. - (void)setBorderWithView:(UIView *)view top:(BOOL)top left:(BOOL)left bottom:(BOOL)bottom right:(BOOL)right borderColor:(UIColor *)color borderWidth:(CGFloat)width;
  34. /// 更新view的约束级别
  35. - (void)updatePriority:(UILayoutPriority)priority;
  36. /// 移除所有子元素
  37. - (void)removeAllSubviews;
  38. ///页面截个图
  39. - (UIImage *)snapshotImage;
  40. ///判断当前view是否显示在Window上
  41. - (BOOL)isShowingOnKeyWindow;
  42. ///通过类名找到子view
  43. - (UIView *)getSubViewWithClassName:(NSString *)className;
  44. @end
  45. /**
  46. * 圆角按钮设置
  47. */
  48. @interface UIButton(cornerBtn)
  49. - (void)setCornerFrame;
  50. @end