UIView继承自UIResponder
常用属性:userInteractionEnabled
tag
layer
常用方法:- (instancetype)initWithFrame:(CGRect)frame
UIView的扩展类(UIViewGeometry)
常用属性:frame
bounds
center
transform
autoresizingMask// simple resize. default is UIViewAutoresizingNone
autoresizesSubviews// default is YES. if set, subviews are adjusted according to their autoresizingMask if self.bounds changes
常用方法:- (CGSize)sizeThatFits:(CGSize)size;// return 'best' size to fit given size. does not actually resize view. Default is return existing view size
- (void)sizeToFit;// calls sizeThatFits: with current view bounds and changes bounds size.
UIView的扩展类(UIViewHierarchy)
常用属性:superview
subviews
常用方法:
- (void)removeFromSuperview;
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;
- (void)addSubview:(UIView *)view;
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
- (void)bringSubviewToFront:(UIView *)view;
- (void)sendSubviewToBack:(UIView *)view;
- (nullable__kindof UIView *)viewWithTag:(NSInteger)tag;// recursive search. includes self
- (void)layoutSubviews; // override point. called by layoutIfNeeded automatically. As of iOS 6.0, when constraints-based layout is used the base implementation applies the constraints-based layout, otherwise it does nothing.
UIView的扩展类(UIViewRendering)
常用属性:clipsToBounds
backgroundColor
alpha
hidden
tintColor
常用方法:- (void)drawRect:(CGRect)rect;
UIView的扩展类(UIViewAnimation)
常用方法:
+ (void)beginAnimations:(nullableNSString *)animationID context:(nullablevoid *)context; // additional context info passed to will start/did stop selectors. begin/commit can be nested
+ (void)commitAnimations;// starts up any animations when the top level animation is commited
+ (void)setAnimationDuration:(NSTimeInterval)duration; // default = 0.2
+ (void)setAnimationDelay:(NSTimeInterval)delay; // default = 0.0
+ (void)setAnimationStartDate:(NSDate *)startDate; // default = now ([NSDate date])
+ (void)setAnimationRepeatCount:(float)repeatCount; // default = 0.0. May be fractional
+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache; // current limitation - only one per begin/commit block
UIView的扩展类(UIViewGestureRecognizers)
常用属性:gestureRecognizers
常用方法:- (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizerNS_AVAILABLE_IOS(3_2);
- (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizerNS_AVAILABLE_IOS(3_2);