UIView+Additions.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // UIViewAdditions.h
  3. //
  4. #import <UIKit/UIKit.h>
  5. #define kScaleX [UIScreen mainScreen].bounds.size.width / 375
  6. #define kScaleY [UIScreen mainScreen].bounds.size.height / 667
  7. //CG_INLINE CGRect CGRectMake_Auto(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
  8. //{
  9. // const CGFloat xScale = [UIScreen mainScreen].bounds.size.width / 375;
  10. // const CGFloat yScale = [UIScreen mainScreen].bounds.size.height / 667;
  11. //
  12. // CGRect rect;
  13. // rect.origin.x = x * xScale;
  14. // rect.origin.y = y * yScale;
  15. // rect.size.width = width * xScale;
  16. // rect.size.height = height * yScale;
  17. //
  18. // return rect;
  19. //}
  20. @interface UIView (Additions)
  21. - (id) initWithParent:(UIView *)parent;
  22. + (id) viewWithParent:(UIView *)parent;
  23. -(void)removeAllSubViews;
  24. - (void)setBackgroundImage:(UIImage*)image;
  25. - (UIImage*)toImage;
  26. // Position of the top-left corner in superview's coordinates
  27. @property CGPoint position;
  28. @property CGFloat x;
  29. @property CGFloat y;
  30. @property CGFloat top;
  31. @property CGFloat bottom;
  32. @property CGFloat left;
  33. @property CGFloat right;
  34. // makes hiding more logical
  35. @property BOOL visible;
  36. // Setting size keeps the position (top-left corner) constant
  37. @property CGSize size;
  38. @property CGFloat width;
  39. @property CGFloat height;
  40. @end
  41. @interface UIImageView (MFAdditions)
  42. - (void) setImageWithName:(NSString *)name;
  43. @end