UIView+YYAdd.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // UIView+YYAdd.h
  3. // YYCategories <https://github.com/ibireme/YYCategories>
  4. //
  5. // Created by ibireme on 13/4/3.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import <UIKit/UIKit.h>
  12. /**
  13. Provides extensions for `UIView`.
  14. */
  15. @interface UIView (YYAdd)
  16. /**
  17. Shortcut to set the view.layer's shadow
  18. @param color Shadow Color
  19. @param offset Shadow offset
  20. @param radius Shadow radius
  21. */
  22. - (void)setLayerShadow:(UIColor*)color offset:(CGSize)offset radius:(CGFloat)radius;
  23. /**
  24. Remove all subviews.
  25. @warning Never call this method inside your view's drawRect: method.
  26. */
  27. - (void)removeAllSubviews;
  28. /**
  29. Returns the view's view controller (may be nil).
  30. */
  31. @property (nonatomic, readonly) UIViewController *viewController;
  32. @property (nonatomic) CGFloat left; ///< Shortcut for frame.origin.x.
  33. @property (nonatomic) CGFloat top; ///< Shortcut for frame.origin.y
  34. @property (nonatomic) CGFloat right; ///< Shortcut for frame.origin.x + frame.size.width
  35. @property (nonatomic) CGFloat bottom; ///< Shortcut for frame.origin.y + frame.size.height
  36. @property (nonatomic) CGFloat width; ///< Shortcut for frame.size.width.
  37. @property (nonatomic) CGFloat height; ///< Shortcut for frame.size.height.
  38. @property (nonatomic) CGFloat centerX; ///< Shortcut for center.x
  39. @property (nonatomic) CGFloat centerY; ///< Shortcut for center.y
  40. @property (nonatomic) CGPoint origin; ///< Shortcut for frame.origin.
  41. @property (nonatomic) CGSize size; ///< Shortcut for frame.size.
  42. @end