黑马程序员技术交流社区

标题: 分类的一些问题 [打印本页]

作者: 每天进步一点点    时间: 2014-7-1 22:26
标题: 分类的一些问题
今天无意中看到苹果官方文档中的一段描述:我看这明显是一个分类的声明,但分类中不是不能增加成员变量吗,请各位大侠帮忙解释一下
  1. @interface UIView(UIViewGeometry)

  2. // animatable. do not use frame if view is transformed since it will not correctly reflect the actual location of the view. use bounds + center instead.
  3. @property(nonatomic) CGRect            frame;

  4. // use bounds/center and not frame if non-identity transform. if bounds dimension is odd, center may be have fractional part
  5. @property(nonatomic) CGRect            bounds;      // default bounds is zero origin, frame size. animatable
  6. @property(nonatomic) CGPoint           center;      // center is center of frame. animatable
  7. @property(nonatomic) CGAffineTransform transform;   // default is CGAffineTransformIdentity. animatable
  8. @property(nonatomic) CGFloat           contentScaleFactor NS_AVAILABLE_IOS(4_0);

  9. @property(nonatomic,getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled;   // default is NO
  10. @property(nonatomic,getter=isExclusiveTouch) BOOL       exclusiveTouch;         // default is NO

  11. - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;   // recursively calls -pointInside:withEvent:. point is in the receiver's coordinate system
  12. - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event;   // default returns YES if point is in bounds

  13. - (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view;
  14. - (CGPoint)convertPoint:(CGPoint)point fromView:(UIView *)view;
  15. - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view;
  16. - (CGRect)convertRect:(CGRect)rect fromView:(UIView *)view;

  17. @property(nonatomic) BOOL               autoresizesSubviews; // default is YES. if set, subviews are adjusted according to their autoresizingMask if self.bounds changes
  18. @property(nonatomic) UIViewAutoresizing autoresizingMask;    // simple resize. default is UIViewAutoresizingNone

  19. - (CGSize)sizeThatFits:(CGSize)size;     // return 'best' size to fit given size. does not actually resize view. Default is return existing view size
  20. - (void)sizeToFit;                       // calls sizeThatFits: with current view bounds and changes bounds size.

  21. @end
复制代码








欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2