UIiew.h的学习理解

@interface UIView : UIResponder


- (id)initWithFrame:(CGRect)frame;

// YES:能够跟用户进行交互
@property(nonatomic,getter=isUserInteractionEnabled ) BOOLuserInteractionEnabled;  // default is YES

// 控件的一个标记(父控件可以通过tag找到对应的子控件)
@property(nonatomic)                                                                NSIntegertag;                              // default is 0

// 图层(可以用来设置圆角效果\阴影效果)
@property(nonatomic,readonly,retain)                                CALayer  *layer;

@end

@interface UIView(UIViewGeometry)
// 位置和尺寸(以父控件的左上角为坐标原点(0, 0))
@property(nonatomic)CGRect                      frame;

// 位置和尺寸(以自己的左上角为坐标原点(0, 0))
@property(nonatomic)CGRect                      bounds;

// 中点(以父控件的左上角为坐标原点(0, 0))
@property(nonatomic)CGPoint                    center;         

// 形变属性(平移\缩放\旋转)
@property(nonatomic) CGAffineTransformtransform;    // default isCGAffineTransformIdentit y

// YES:支持多点触摸
@property(nonatomic,getter=isMultipleTouchEnabled) BOOLmultipleTouchEnabled;    //default is NO
@end

@interface UIView(UIViewHierarchy)
// 父控件
@property(nonatomic,readonly)UIView            *superview;

// 子控件(新添加的控件默认都在subviews数组的后面, 新添加的控件默认都显示在最上面\最顶部)
@property(nonatomic,readonly,copy) NSArray *subviews;

// 获得当前控件所在的window
@property(nonatomic,readonly)UIWindow        *window;

// 从父控件中移除一个控件
- (void)removeFromSuperview;

// 添加一个子控件(可以将子控件插入到subviews数组中index这个位置)
- (void)insertSubview:(UIView *)viewatIndex:(NSInteger)index;

// 交换subviews数组中所存放子控件的位置
- (void)exchangeSubviewAtIndex:(NSInteger)index1withSubviewAtIndex:(NSInteger)index2;

// 添加一个子控件(新添加的控件默认都在subviews数组的后面, 新添加的控件默认都显示在最上面\最顶部)
- (void)addSubview:(UIView *)view;

// 添加一个子控件view(被挡在siblingSubview的下面)
- (void)insertSubview:(UIView *)view belowSubview:(UIView*)siblingSubview;

// 添加一个子控件view(盖在siblingSubview的上面)
- (void)insertSubview:(UIView *)view aboveSubview:(UIView*)siblingSubview;

// 将某个子控件拉到最上面(最顶部)来显示
- (void)bringSubviewToFront:(UIView *)view;

// 将某个子控件拉到最下面(最底部)来显示
- (void)sendSubviewToBack:(UIView *)view;


- (void)didAddSubview:(UIView *)subview;
- (void)willRemoveSubview:(UIView *)subview;

- (void)willMoveToSuperview:(UIView *)newSuperview;
- (void)didMoveToSuperview;
- (void)willMoveToWindow:(UIWindow *)newWindow;
- (void)didMoveToWindow;


// 是不是view的子控件或者子控件的子控件(是否为view的后代)
- (BOOL)isDescendantOfView:(UIView *)view;  //returns YES for self.

// 通过tag获得对应的子控件(也可以或者子控件的子控件)
- (UIView*)viewWithTag:(NSInteger)tag;        // recursive search. includes self


// 控件的frame发生改变的时候就会调用,一般在这里重写布局子控件的位置和尺寸
// 重写了这个写方法后,一定调用[super layoutSubviews];
- (void)layoutSubviews;

@end

@interface UIView(UIViewRendering)
// YES : 超出控件边框范围的内容都剪掉
@property(nonatomic)                                BOOL                          clipsToBounds;

// 背景色
@property(nonatomic,copy)                      UIColor                  *backgroundColor; // default is nil

// 透明度(0.0~1.0)
@property(nonatomic)                                CGFloat                    alpha;                                          // default is 1.0

// YES:不透明  NO:透明
@property(nonatomic,getter=isOpaque)BOOL                          opaque;                                        // default is YES

// YES : 隐藏  NO : 显示
@property(nonatomic,getter=isHidden)BOOL                          hidden;

// 内容模式
@property(nonatomic)                                UIViewContentModecontentMode;                              // default is UIViewContentModeScaleTo Fill
@end

@interface UIView(UIViewAnimationWithBlock s)
+ (void)animateWithDuration:(NSTimeInterval)durationdelay:(NSTimeInterval)delay options:(UIViewAnimationOptions)optionsanimations:(void (^)(void))animations completion:(void (^)(BOOLfinished))completion;
+ (void)animateWithDuration:(NSTimeInterval)durationanimations:(void (^)(void))animations completion:(void (^)(BOOLfinished))completion;

+ (void)animateWithDuration:(NSTimeInterval)durationanimations:(void (^)(void))animations;
+ (void)animateWithDuration:(NSTimeInterval)durationdelay:(NSTimeInterval)delayusingSpringWithDamping:(CGFloat)dampingRatioinitialSpringVelocity:(CGFloat)velocityoptions:(UIViewAnimationOptions)options animations:(void(^)(void))animations completion:(void (^)(BOOLfinished))completion;
@end
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值