//
//UIView.h
//UIKit
//
//Copyright (c) 2005-2015 Apple Inc. All rights reserved.
//
注释,没什么好说的,说是UIView.h,在UIKit框架里,版权在2005-2015年里是苹果公司的,所有权利保留.
#import<Foundation/Foundation.h>导入基础框架,与#import<Foundation.h>区别是前者直接去系统目录找,不会浪费时间在用户目录.
竟然复制不了,那就截图先.导入uikit框架下各种类,UIResponder响应类,UIInterface图形界面类,UIKitDefines定义,UIAppearance表现,UIDynamicBehavior动态行为,NSLayoutConstraint布局约束,UITraitCollection特点,UIFocus中心
NS_ASSUME_NONNULL_BEGIN 宏定义,我从这里开始了
typedefNS_ENUM(NSInteger, UIViewAnimationCurve) {
UIViewAnimationCurveEaseInOut,// slow at beginning and end 缓慢地在开始和结束的地方渐进
UIViewAnimationCurveEaseIn,// slow at beginning 渐进在开始的地方
UIViewAnimationCurveEaseOut,// slow at end 渐进在结束的地方
UIViewAnimationCurveLinear 动画曲线线性的
};定义NSInteger类型的名叫UIViewAnimationCurve的枚举
typedefNS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeScaleToFill,按比例填充
UIViewContentModeScaleAspectFit,// contents scaled to fit with fixed aspect. remainder is transparent 按比例去适应固定图形,余下透明
UIViewContentModeScaleAspectFill,// contents scaled to fill with fixed aspect. some portion of content may be clipped.按比例去填充固定图形,一部分会被切掉
UIViewContentModeRedraw,// redraw on bounds change (calls -setNeedsDisplay)重画在界线改变(通过调用setNeedsDisplay方法)
UIViewContentModeCenter,// contents remain same size. positioned adjusted.内容保持不变,位置适应
UIViewContentModeTop,上
UIViewContentModeBottom,下
UIViewContentModeLeft,左
UIViewContentModeRight,右
UIViewContentModeTopLeft,上左
UIViewContentModeTopRight,下右
UIViewContentModeBottomLeft,下左
UIViewContentModeBottomRight,下右
};定义NSInteger类型的叫UIViewContentMode的枚举
typedefNS_ENUM(NSInteger, UIViewAnimationTransition) {
UIViewAnimationTransitionNone,//动画轨迹无
UIViewAnimationTransitionFlipFromLeft,//从左边弹出
UIViewAnimationTransitionFlipFromRight,//从右边弹出
UIViewAnimationTransitionCurlUp,//从上面卷起
UIViewAnimationTransitionCurlDown,//从下面卷起
};定义NSInteger类型的叫UIViewAnimationTransition的枚举
typedefNS_OPTIONS(NSUInteger, UIViewAutoresizing) {
UIViewAutoresizingNone=0,//自适应无
UIViewAutoresizingFlexibleLeftMargin=1<<0,//弯曲左边距离
UIViewAutoresizingFlexibleWidth=1<<1,//弯曲宽度
UIViewAutoresizingFlexibleRightMargin=1<<2,//弯曲右边距离
UIViewAutoresizingFlexibleTopMargin=1<<3,//弯曲上边宽度
UIViewAutoresizingFlexibleHeight=1<<4,//弯曲高度
UIViewAutoresizingFlexibleBottomMargin =1<<5//弯曲底部距离
};定义NSUInteger类型名叫UIViewAutoresizing的枚举
typedefNS_OPTIONS(NSUInteger, UIViewAnimationOptions) {
UIViewAnimationOptionLayoutSubviews=1<<0,//布局子view
UIViewAnimationOptionAllowUserInteraction=1<<1,// turn on user interaction while animating//打开用户交互当动画时候
UIViewAnimationOptionBeginFromCurrentState=1<<2,// start all views from current value, not initial value//开始所有的view从现在值,不是实例化的值
UIViewAnimationOptionRepeat=1<<3,// repeat animation indefinitely无限地重复动画
UIViewAnimationOptionAutoreverse=1<<4,// if repeat, run animation back and forth
//如果重复,运行动画后面和向前
UIViewAnimationOptionOverrideInheritedDuration =1<<5,// ignore nested duration
//不管内装的持续
UIViewAnimationOptionOverrideInheritedCurve=1<<6,// ignore nested curve
//不管内装的曲线
UIViewAnimationOptionAllowAnimatedContent=1<<7,// animate contents (applies to transitions only)//允许动画内容(仅仅在应用转换时)
UIViewAnimationOptionShowHideTransitionViews=1<<8,// flip to/from hidden state instead of adding/removing//跳出或者隐藏状态而不是添加和移除
UIViewAnimationOptionOverrideInheritedOptions=1<<9,// do not inherit any options or animation type//不在继承任何可选项和动画类型
UIViewAnimationOptionCurveEaseInOut=0<<16,// default 默认 淡入淡出
UIViewAnimationOptionCurveEaseIn=1<<16, 淡入
UIViewAnimationOptionCurveEaseOut=2<<16, 淡出
UIViewAnimationOptionCurveLinear=3<<16, 线性曲线
UIViewAnimationOptionTransitionNone=0<<20,// default 转变没有
UIViewAnimationOptionTransitionFlipFromLeft=1<<20, 从左边飞入
UIViewAnimationOptionTransitionFlipFromRight=2<<20,从右边飞入
UIViewAnimationOptionTransitionCurlUp=3<<20,//往上卷
UIViewAnimationOptionTransitionCurlDown=4<<20,//往下卷
UIViewAnimationOptionTransitionCrossDissolve=5<<20,//十字消失
UIViewAnimationOptionTransitionFlipFromTop=6<<20,//从上面飞入
UIViewAnimationOptionTransitionFlipFromBottom=7<<20,//从下面飞入
}NS_ENUM_AVAILABLE_IOS(4_0);//ios4.0以后可用
//定义NSUInteger类型叫UIViewAnimationOptions的枚举
typedefNS_OPTIONS(NSUInteger, UIViewKeyframeAnimationOptions) {
UIViewKeyframeAnimationOptionLayoutSubviews=UIViewAnimationOptionLayoutSubviews,//两个等价
UIViewKeyframeAnimationOptionAllowUserInteraction=UIViewAnimationOptionAllowUserInteraction,// turn on user interaction while animating 等价//开启用户交互当在动画的时候
UIViewKeyframeAnimationOptionBeginFromCurrentState=UIViewAnimationOptionBeginFromCurrentState,// start all views from current value, not initial value
UIViewKeyframeAnimationOptionRepeat=UIViewAnimationOptionRepeat,// repeat animation indefinitely
UIViewKeyframeAnimationOptionAutoreverse=UIViewAnimationOptionAutoreverse,// if repeat, run animation back and forth
UIViewKeyframeAnimationOptionOverrideInheritedDuration =UIViewAnimationOptionOverrideInheritedDuration,// ignore nested duration
UIViewKeyframeAnimationOptionOverrideInheritedOptions=UIViewAnimationOptionOverrideInheritedOptions,// do not inherit any options or animation type
UIViewKeyframeAnimationOptionCalculationModeLinear=0<<10,// default线性
UIViewKeyframeAnimationOptionCalculationModeDiscrete=1<<10,离散的
UIViewKeyframeAnimationOptionCalculationModePaced=2<<10,步调的
UIViewKeyframeAnimationOptionCalculationModeCubic=3<<10,立体
UIViewKeyframeAnimationOptionCalculationModeCubicPaced =4<<10立体步调
}NS_ENUM_AVAILABLE_IOS(7_0);ios7.0之后可用
//定义NSUInteger类型名叫UIViewKeyframeAnimationOptions
typedefNS_ENUM(NSUInteger, UISystemAnimation) {
UISystemAnimationDelete,// removes the views from the hierarchy when complete
当完成时移除view从父类
}NS_ENUM_AVAILABLE_IOS(7_0);
//定义NSUInteger类型的UISystemAnimation(系统动画)
typedefNS_ENUM(NSInteger, UIViewTintAdjustmentMode) {
UIViewTintAdjustmentModeAutomatic,//tint自适应
UIViewTintAdjustmentModeNormal,//tint正常适应
UIViewTintAdjustmentModeDimmed,//tint适应无效
}NS_ENUM_AVAILABLE_IOS(7_0);ios7.0之后可用
//定义NSInteger类型的名叫UIViewTintAdjustmentMode的枚举
typedefNS_ENUM(NSInteger, UISemanticContentAttribute) {
UISemanticContentAttributeUnspecified =0,//语义内容未指明
UISemanticContentAttributePlayback,// for playback controls such as Play/RW/FF buttons and playhead scrubbers//适合于回放控制例如Play/RW/FF按钮和播放头洗涤器
UISemanticContentAttributeSpatial,// for controls that result in some sort of directional change in the UI, e.g. a segmented control for text alignment or a D-pad in a game
//适合于控制那些稍微方向改变在ui.例如 一个语句控制对文本对齐或者 一个d-pad 在游戏中
UISemanticContentAttributeForceLeftToRight,从左往右
UISemanticContentAttributeForceRightToLeft从右往左
}NS_ENUM_AVAILABLE_IOS(9_0);ios9.0之后可用
//定义NSInteger类型的名叫UISemanticContentAttribute枚举
typedefNS_ENUM(NSInteger, UIUserInterfaceLayoutDirection) {
UIUserInterfaceLayoutDirectionLeftToRight,//用户交互布局从左至右
UIUserInterfaceLayoutDirectionRightToLeft,//用户交互从右至左
}NS_ENUM_AVAILABLE_IOS(5_0);//ios5.0之后可用
//定义NSInteger类型的UIUserInterfaceLayoutDirection枚举
@protocol UICoordinateSpace <NSObjec>//定义名为UICoordinateSpace的协议(坐标空间)
- (CGPoint)convertPoint:(CGPoint)point toCoordinateSpace:(id)coordinateSpace NS_AVAILABLE_IOS(8_0);//相对于某个坐标转换坐标 ios8.0之后可用
- (CGPoint)convertPoint:(CGPoint)point fromCoordinateSpace:(id)coordinateSpaceNS_AVAILABLE_IOS(8_0);//从坐标转换坐标
- (CGRect)convertRect:(CGRect)rect toCoordinateSpace:(id)coordinateSpaceNS_AVAILABLE_IOS(8_0);//相对于可见区域转换区域
- (CGRect)convertRect:(CGRect)rect fromCoordinateSpace:(id)coordinateSpaceNS_AVAILABLE_IOS(8_0);//从可见区域转换区域
@property(readonly,nonatomic)CGRect bounds NS_AVAILABLE_IOS(8_0);只读协议bounds属性
@end
@classUIBezierPath,UIEvent,UIWindow,UIViewController,UIColor,UIGestureRecognizer,UIMotionEffect,CALayer,UILayoutGuide;//告诉编译器这些都是类,运行时帮我导入
//贝塞尔路径,ui事件,ui窗口,ui控制器,ui颜色,ui手势识别,ui起作用的移动,calayer,ui布局指南
NS_CLASS_AVAILABLE_IOS(2_0)@interfaceUIView :UIResponder<NSCoding,UIAppearance,UIAppearanceContainer,UIDynamicItem,UITraitEnvironment,UICoordinateSpace,UIFocusEnvironment>
+ (Class)layerClass;// default is [CALayer class]. Used when creating the underlying layer for the view.//默认是[CALayer class],使用当创建在view下面的layer时.
- (instancetype)initWithFrame:(CGRect)frameNS_DESIGNATED_INITIALIZER;
//实例初始frame
- (nullableinstancetype)initWithCoder:(NSCoder*)aDecoderNS_DESIGNATED_INITIALIZER; //实例化从序列化
@property(nonatomic,getter=isUserInteractionEnabled)BOOLuserInteractionEnabled;// default is YES. if set to NO, user events (touch, keys) are ignored and removed from the event queue.//默认是yes,如果设置成no,那么用户事件(触摸,键入)都不管和移除从这个事件队列.
@property(nonatomic)NSInteger tag;// default is 0 每一个控件都有tag值,默认为0
@property(nonatomic,readonly,strong)CALayer*layer;// returns view's layer. Will always return a non-nil value. view is layer's delegate //返回view的layer,教会一直返回a一个不为空的值.view是layer的代理.
- (BOOL)canBecomeFocused NS_AVAILABLE_IOS(9_0);// NO by default //可成为焦点,默认为no
@property(readonly,nonatomic,getter=isFocused)BOOL focusedNS_AVAILABLE_IOS(9_0); 只读属性
+ (UIUserInterfaceLayoutDirection)userInterfaceLayoutDirectionForSemanticContentAttribute:(UISemanticContentAttribute)attributeNS_AVAILABLE_IOS(9_0);用户交互布局继承从语义内容属性
@property(nonatomic)UISemanticContentAttribute semanticContentAttributeNS_AVAILABLE_IOS(9_0);//语义布局属性
@end
@interfaceUIView(UIViewGeometry)//分类 关于uivew几何方面的
// 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.
//可动画.不要使用frame当view是转换因为它不会正确地反应实际位置在这个view上.使用bouns+center替代.
@property(nonatomic)CGRect frame;
// use bounds/center and not frame if non-identity transform. if bounds dimension is odd, center may be have fractional part //使用bouns/center 和不是frame如果不能同一转换.如果bounds的尺寸增加了,中心可能 有部分的部分
@property(nonatomic)CGRect bounds;// default bounds is zero origin, frame size. animatable //默认是0,0,frame的size,可动画.
@property(nonatomic)CGPoint center;// center is center of frame. animatable 中心是frame的中心,可动画.
@property(nonatomic)CGAffineTransform transform;// default is CGAffineTransformIdentity. animatable//默认是[100100]可动画
@property(nonatomic)CGFloat contentScaleFactor NS_AVAILABLE_IOS(4_0);//内容缩放比例
@property(nonatomic,getter=isMultipleTouchEnabled)BOO LmultipleTouchEnabled__TVOS_PROHIBITED;// default is NO //多点触碰,默认为no
@property(nonatomic,getter=isExclusiveTouch)BOOL exclusiveTouch__TVOS_PROHIBITED;// default is NO 唯一触摸,默认为no
- (nullableUIView*)hitTest:(CGPoint)point withEvent:(nullableUIEvent*)event;// recursively calls -pointInside:withEvent:. point is in the receiver's coordinate system递归地访问 -pointInside:withEvent,点是在接受者的坐标系统内.
- (BOOL)pointInside:(CGPoint)point withEvent:(nullableUIEvent*)event;// default returns YES if point is in bounds 如果点在这个区域内就默认返回yes
- (CGPoint)convertPoint:(CGPoint)point toView:(nullableUIView*)view;//基于view转换点
- (CGPoint)convertPoint:(CGPoint)point fromView:(nullableUIView*)view;//从view去点
- (CGRect)convertRect:(CGRect)rect toView:(nullableUIView*)view;//基于view转换区域
- (CGRect)convertRect:(CGRect)rect fromView:(nullableUIView*)view;//从view取点
@property(nonatomic)BOOL autoresizesSubviews;// default is YES. if set, subviews are adjusted according to their autoresizingMask if self.bounds changes//自动适应布局子view,默认是yes,如果设置的话,子view会按照他们的autoresizingMask来适应如果自身的bouns改变的话,
@property(nonatomic)UIViewAutoresizing autoresizingMask;// simple resize. default is UIViewAutoresizingNone//单纯调整大小,默认是UIViewAutoresizingNone
- (CGSize)sizeThatFits:(CGSize)size;// return 'best' size to fit given size. does not actually resize view. Default is return existing view size//返回最合适大小去适应给定大小.不实际调整view.默认返回已经存在的view的大小.
- (void)sizeToFit;// calls sizeThatFits: with current view bounds and changes bounds size.
//调用sizeThatFits,和现在view的bouns和改变bouns大小.
@end
@interfaceUIView(UIViewHierarchy) //uivew层级
@property(nullable,nonatomic,readonly)UIView*superview;//父类
@property(nonatomic,readonly,copy)NSArray<__kindofUIView*> *subviews;//子类
@property(nullable,nonatomic,readonly)UIWindow*window;//窗口
- (void)removeFromSuperview;//从父类移除
- (void)insertSubview:(UIView*)view atIndex:(NSInteger)index;//插入子view在哪个下标
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;//交换子view在下标1和子view在下标2
- (void)addSubview:(UIView*)view;//添加子view
- (void)insertSubview:(UIView*)view belowSubview:(UIView*)siblingSubview;插入子view在某个view的下面
- (void)insertSubview:(UIView*)view aboveSubview:(UIView*)siblingSubview;//插入子view在某个子view的上面
- (void)bringSubviewToFront:(UIView*)view;//把子view带到根
- (void)sendSubviewToBack:(UIView*)view;//把子view放到后面
- (void)didAddSubview:(UIView*)subview;//已经添加了子view
- (void)willRemoveSubview:(UIView*)subview;//将要移除子view
- (void)willMoveToSuperview:(nullableUIView*)newSuperview;//将要移动到新父view
- (void)didMoveToSuperview;//已经移动到父view
- (void)willMoveToWindow:(nullableUIWindow*)newWindow;//将会移动到新窗口
- (void)didMoveToWindow;//已经移动到新窗口
- (BOOL)isDescendantOfView:(UIView*)view;// returns YES for self.//是否是某个view的后代//默认是yes对于自己
- (nullable__kindofUIView*)viewWithTag:(NSInteger)tag;// recursive search. includes self
//递归地探究,包括自己
// Allows you to perform layout before the drawing cycle happens. -layoutIfNeeded forces layout early//允许你去执行布局在绘画循环发生之前.-layoutIfNeeded强制刷新更早.
- (void)setNeedsLayout;//标记需要刷新
- (void)layoutIfNeeded;//立即强制刷新
- (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.//不管点访问通过layoutIfNeeded自动的.自6.0起,当基本约束布局是使用基本实现应用基本约束布局才起作用,否则啥都不干.
/*
-layoutMargins returns a set of insets from the edge of the view's bounds that denote a default spacing for laying out content.//-layoutMargins返回一系列内边距在view的bouns,那表示有默认空间在布局内容时.
If preservesSuperviewLayoutMargins is YES, margins cascade down the view tree, //如果保存父view布局间距是yes的话,间距串联下来这个view树
adjusting for geometry offsets, so that setting the left value of layoutMargins on a superview will affect the left value of layoutMargins for subviews positioned close to the left edge of their superview's bounds
//适应几何学偏移量,因此设置左边布局间距在一个父view将会影响左边布局间距值对父类位置靠近这个左边间距对他们父类的界线
If your view subclass uses layoutMargins in its layout or drawing, override -layoutMarginsDidChange in order to refresh your view if the margins change.
//如果你的view的子类使用layoutMargins在你布局或者绘画时,override -layoutMarginsDidChange目的是为了刷新你的view如果间距改变的话.
*/
@property(nonatomic)UIEdgeInsets layoutMarginsNS_AVAILABLE_IOS(8_0);
@property(nonatomic)BOOL preservesSuperviewLayoutMarginsNS_AVAILABLE_IOS(8_0);// default is NO - set to enable pass-through or cascading behavior of margins from this view’s parent to its children//默认为no,设置去转嫁或者串联行为的间距从view的父类去他的孩子.
- (void)layoutMarginsDidChangeNS_AVAILABLE_IOS(8_0);
/* The edges of this guide are constrained to equal the edges of the view inset by the layoutMargins//这指南的边界都是约束去等同于view的内边距通过布局间距
*/
@property(readonly,strong)UILayoutGuide*layoutMarginsGuideNS_AVAILABLE_IOS(9_0);
/// This content guide provides a layout area that you can use to place text and related content whose width should generally be constrained to a size that is easy for the user to read. This guide provides a centered region that you can place content within to get this behavior for this view.//这个内容指南提供一个布局区域,是你可以使用放置文本和相关文本,它的宽度应该一般约束去一个尺寸,它很容易去使用和阅读.
@property(nonatomic,readonly,strong)UILayoutGuide*readableContentGuideNS_AVAILABLE_IOS(9_0);
@end
@interfaceUIView(UIViewRendering) uiview渲染
- (void)drawRect:(CGRect)rect;//绘制可见区域
- (void)setNeedsDisplay;//标记需要重新绘制
- (void)setNeedsDisplayInRect:(CGRect)rect;//标记在哪需要绘制
@property(nonatomic)BOOLclipsToBounds;// When YES, content and subviews are clipped to the bounds of the view. Default is NO.超出部分需要剪切吗?默认为no
@property(nullable,nonatomic,copy)UIColor*backgroundColorUI_APPEARANCE_SELECTOR;// default is nil. Can be useful with the appearance proxy on custom UIView subclasses.//背景颜色,
@property(nonatomic)CGFloat alpha;// animatable. default is 1.0 可动画,透明度,默认为1,不透明
@property(nonatomic,getter=isOpaque)BOOL opaque;// default is YES. opaque views must fill their entire bounds or the results are undefined. the active CGContext in drawRect: will not have been cleared and may have non-zeroed pixels//是否不透明,默认是yes,不透明view必须填充他们整个边界或者结果是未定义的.这个活跃上下文在绘制区域将不会被清除和可能有不为空的像素.
@property(nonatomic)BOOL clearsContextBeforeDrawing;// default is YES. ignored for opaque views. for non-opaque views causes the active CGContext in drawRect: to be pre-filled with transparent pixels//清除上下文在绘制的时候//默认是yes,不管不透明的view因为透明的view导致活跃上下文在绘制区域方法提前填充透明的像素.
@property(nonatomic,getter=isHidden)BOOL hidden;// default is NO. doesn't check superviews//是否隐藏 默认为no,不检查父view.
@property(nonatomic)UIViewContentMode contentMode;// default is UIViewContentModeScaleToFill //内容填充模式 //默认是按比例去填充
@property(nonatomic)CGRect contentStretchNS_DEPRECATED_IOS(3_0,6_0)__TVOS_PROHIBITED;// animatable. default is unit rectangle {{0,0} {1,1}}. Now deprecated: please use -[UIImage resizableImageWithCapInsets:] to achieve the same effect.//可动画,默认是单元长方形0011,现在弃用,请使用-[UIImage resizableImageWithCapInsets:]去取得同样的效果
@property(nullable,nonatomic,strong)UIView*maskViewNS_AVAILABLE_IOS(8_0);//遮罩view
/*
-tintColor always returns a color. The color returned is the first non-default value in the receiver's superview chain (starting with itself).//-tintColor总是返回一个颜色.颜色返回第一个不默认的值在接受者的父view链(从自己开始)
If no non-default value is found, a system-defined color is returned.//如果没有默认的值找到,一个系统定义的颜色会被返回.
If this view's -tintAdjustmentMode returns Dimmed, then the color that is returned for -tintColor will automatically be dimmed.如果这个view的tintAdjustmentMode方法返回无效,然后这个颜色返回tintColor将会自动无效.
If your view subclass uses tintColor in its rendering, override -tintColorDidChange in order to refresh the rendering if the color changes.如果你的view字类使用了tintColor在他的渲染里,重写tintColorDidChange方法目的是去刷新渲染如果颜色改变的话.
*/
@property(null_resettable,nonatomic,strong)UIColor*tintColorNS_AVAILABLE_IOS(7_0);
/*
-tintAdjustmentMode always returns either UIViewTintAdjustmentModeNormal or UIViewTintAdjustmentModeDimmed. The value returned is the first non-default value in the receiver's superview chain (starting with itself).//tintAdjustmentMode经常返回UIViewTintAdjustmentModeNormal和UIViewTintAdjustmentModeDimmed中的一个.这个值返回第一个不为默认值在接受者的链条(从自己开始)
If no non-default value is found, UIViewTintAdjustmentModeNormal is returned.//如果没有找到不是默认值的话,UIViewTintAdjustmentModeNormal将会返回.
When tintAdjustmentMode has a value of UIViewTintAdjustmentModeDimmed for a view, the color it returns from tintColor will be modified to give a dimmed appearance.//当tintAdjustmentMode有一个值UIViewTintAdjustmentModeDimmed对于一个view来说,这颜色返回从tintColor将会被修改去给一个暗色表现.
When the tintAdjustmentMode of a view changes (either the view's value changing or by one of its superview's values changing), -tintColorDidChange will be called to allow the view to refresh its rendering.当一个view的tintAdjustmentMode(view的值改变或者父类值改变)tintColorDidChange将会被调用去允许view去刷新他的渲染.
*/
@property(nonatomic)UIViewTintAdjustmentMode tintAdjustmentModeNS_AVAILABLE_IOS(7_0);
/*
The -tintColorDidChange message is sent to appropriate subviews of a view when its tintColor is changed by client code or to subviews in the view hierarchy of a view whose tintColor is implicitly changed when its superview or tintAdjustmentMode changes.
*///tintColorDidChange这个方法消息是发送给适当的子view当tintColor被改变通过客户端代码或者子view在view的view层级,他的tintColor是暗中改变当他的父view或者tintAdjustmentMode改变.
- (void)tintColorDidChangeNS_AVAILABLE_IOS(7_0);
@end
@interfaceUIView(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
// no getters. if called outside animation block, these setters have no effect.
+ (void)setAnimationDelegate:(nullableid)delegate;// default = nil
+ (void)setAnimationWillStartSelector:(nullableSEL)selector;// default = NULL. -animationWillStart:(NSString *)animationID context:(void *)context
+ (void)setAnimationDidStopSelector:(nullableSEL)selector;// default = NULL. -animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
+ (void)setAnimationDuration:(NSTimeInterval)duration;// default = 0.2
+ (void)setAnimationDelay:(NSTimeInterval)delay;// default = 0.0
+ (void)setAnimationStartDate:(NSDate*)startDate;// default = now ([NSDate date])
+ (void)setAnimationCurve:(UIViewAnimationCurve)curve;// default = UIViewAnimationCurveEaseInOut
+ (void)setAnimationRepeatCount:(float)repeatCount;// default = 0.0.May be fractional
+ (void)setAnimationRepeatAutoreverses:(BOOL)repeatAutoreverses;// default = NO. used if repeat count is non-zero
+ (void)setAnimationBeginsFromCurrentState:(BOOL)fromCurrentState;// default = NO. If YES, the current view position is always used for new animations -- allowing animations to "pile up" on each other. Otherwise, the last end state is used for the animation (the default).
+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView*)view cache:(BOOL)cache;// current limitation - only one per begin/commit block
+ (void)setAnimationsEnabled:(BOOL)enabled;// ignore any attribute changes while set.
+ (BOOL)areAnimationsEnabled;
+ (void)performWithoutAnimation:(void(^)(void))actionsWithoutAnimationNS_AVAILABLE_IOS(7_0);
+ (NSTimeInterval)inheritedAnimationDurationNS_AVAILABLE_IOS(9_0);
@end
@interfaceUIView(UIViewAnimationWithBlocks)//动画block
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void(^)(void))animations completion:(void(^__nullable)(BOOLfinished))completionNS_AVAILABLE_IOS(4_0);
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void(^)(void))animations completion:(void(^__nullable)(BOOLfinished))completionNS_AVAILABLE_IOS(4_0);// delay = 0.0, options = 0
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void(^)(void))animationsNS_AVAILABLE_IOS(4_0);// delay = 0.0, options = 0, completion = NULL
/* Performs `animations` using a timing curve described by the motion of a spring. When `dampingRatio` is 1, the animation will smoothly decelerate to its final model values without oscillating. Damping ratios less than 1 will oscillate more and more before coming to a complete stop. You can use the initial spring velocity to specify how fast the object at the end of the simulated spring was moving before it was attached. It's a unit coordinate system, where 1 is defined as travelling the total animation distance in a second. So if you're changing an object's position by 200pt in this animation, and you want the animation to behave as if the object was moving at 100pt/s before the animation started, you'd pass 0.5. You'll typically want to pass 0 for the velocity. */
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void(^)(void))animations completion:(void(^__nullable)(BOOLfinished))completionNS_AVAILABLE_IOS(7_0);
+ (void)transitionWithView:(UIView*)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void(^__nullable)(void))animations completion:(void(^__nullable)(BOOLfinished))completionNS_AVAILABLE_IOS(4_0);
+ (void)transitionFromView:(UIView*)fromView toView:(UIView*)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void(^__nullable)(BOOLfinished))completionNS_AVAILABLE_IOS(4_0);// toView added to fromView.superview, fromView removed from its superview
/* Performs the requested system-provided animation on one or more views. Specify addtional animations in the parallelAnimations block. These additional animations will run alongside the system animation with the same timing and duration that the system animation defines/inherits. Additional animations should not modify properties of the view on which the system animation is being performed. Not all system animations honor all available options.
*/
+ (void)performSystemAnimation:(UISystemAnimation)animation onViews:(NSArray<__kindofUIView*> *)views options:(UIViewAnimationOptions)options animations:(void(^__nullable)(void))parallelAnimations completion:(void(^__nullable)(BOOLfinished))completionNS_AVAILABLE_IOS(7_0);
@end
@interfaceUIView (UIViewKeyframeAnimations)//核心架构动画
+ (void)animateKeyframesWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options animations:(void(^)(void))animations completion:(void(^__nullable)(BOOLfinished))completionNS_AVAILABLE_IOS(7_0);
+ (void)addKeyframeWithRelativeStartTime:(double)frameStartTime relativeDuration:(double)frameDuration animations:(void(^)(void))animationsNS_AVAILABLE_IOS(7_0);// start time and duration are values between 0.0 and 1.0 specifying time and duration relative to the overall time of the keyframe animation
@end
@interfaceUIView (UIViewGestureRecognizers)//手势识别
@property(nullable,nonatomic,copy)NSArray<__kindofUIGestureRecognizer*> *gestureRecognizersNS_AVAILABLE_IOS(3_2);
- (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizerNS_AVAILABLE_IOS(3_2);
- (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizerNS_AVAILABLE_IOS(3_2);
// called when the recognizer attempts to transition out of UIGestureRecognizerStatePossible if a touch hit-tested to this view will be cancelled as a result of gesture recognition
// returns YES by default. return NO to cause the gesture recognizer to transition to UIGestureRecognizerStateFailed
// subclasses may override to prevent recognition of particular gestures. for example, UISlider prevents swipes parallel to the slider that start in the thumb
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizerNS_AVAILABLE_IOS(6_0);
@end
@interfaceUIView (UIViewMotionEffects)//动作效果
/*! Begins applying `effect` to the receiver. The effect's emitted keyPath/value pairs will be
applied to the view's presentation layer.
Animates the transition to the motion effect's values using the present UIView animation
context. */
- (void)addMotionEffect:(UIMotionEffect*)effectNS_AVAILABLE_IOS(7_0);
/*! Stops applying `effect` to the receiver. Any affected presentation values will animate to
their post-removal values using the present UIView animation context. */
- (void)removeMotionEffect:(UIMotionEffect*)effectNS_AVAILABLE_IOS(7_0);
@property(copy,nonatomic)NSArray<__kindofUIMotionEffect*> *motionEffectsNS_AVAILABLE_IOS(7_0);
@end
//
// UIView Constraint-based Layout Support
//
typedefNS_ENUM(NSInteger, UILayoutConstraintAxis) {
UILayoutConstraintAxisHorizontal =0,
UILayoutConstraintAxisVertical =1
};
// Installing Constraints
/* A constraint is typically installed on the closest common ancestor of the views involved in the constraint.
It is required that a constraint be installed on _a_ common ancestor of every view involved.The numbers in a constraint are interpreted in the coordinate system of the view it is installed on.A view is considered to be an ancestor of itself.
*/
@interfaceUIView (UIConstraintBasedLayoutInstallingConstraints)//约束基于布局
@property(nonatomic,readonly)NSArray<__kindofNSLayoutConstraint*> *constraintsNS_AVAILABLE_IOS(6_0);
- (void)addConstraint:(NSLayoutConstraint*)constraintNS_AVAILABLE_IOS(6_0);// This method will be deprecated in a future release and should be avoided. Instead, set NSLayoutConstraint's active property to YES.
- (void)addConstraints:(NSArray<__kindofNSLayoutConstraint*> *)constraintsNS_AVAILABLE_IOS(6_0);// This method will be deprecated in a future release and should be avoided. Instead use +[NSLayoutConstraint activateConstraints:].
- (void)removeConstraint:(NSLayoutConstraint*)constraintNS_AVAILABLE_IOS(6_0);// This method will be deprecated in a future release and should be avoided. Instead set NSLayoutConstraint's active property to NO.
- (void)removeConstraints:(NSArray<__kindofNSLayoutConstraint*> *)constraintsNS_AVAILABLE_IOS(6_0);// This method will be deprecated in a future release and should be avoided. Instead use +[NSLayoutConstraint deactivateConstraints:].
@end
// Core Layout Methods
/* To render a window, the following passes will occur, if necessary.
update constraints
layout
display
Please see the conceptual documentation for a discussion of these methods.
*/
@interfaceUIView (UIConstraintBasedLayoutCoreMethods)//核心布局方法
- (void)updateConstraintsIfNeededNS_AVAILABLE_IOS(6_0);// Updates the constraints from the bottom up for the view hierarchy rooted at the receiver. UIWindow's implementation creates a layout engine if necessary first.
- (void)updateConstraintsNS_AVAILABLE_IOS(6_0);// Override this to adjust your special constraints during a constraints update pass
- (BOOL)needsUpdateConstraintsNS_AVAILABLE_IOS(6_0);
- (void)setNeedsUpdateConstraintsNS_AVAILABLE_IOS(6_0);
@end
// Compatibility and Adoption
@interfaceUIView (UIConstraintBasedCompatibility)//布局兼容性
/* By default, the autoresizing mask on a view gives rise to constraints that fully determine
the view's position. This allows the auto layout system to track the frames of views whose
layout is controlled manually (through -setFrame:, for example).
When you elect to position the view using auto layout by adding your own constraints,
you must set this property to NO. IB will do this for you.
*/
@property(nonatomic)BOOLtranslatesAutoresizingMaskIntoConstraintsNS_AVAILABLE_IOS(6_0);// Default YES
/* constraint-based layout engages lazily when someone tries to use it (e.g., adds a constraint to a view).If you do all of your constraint set up in -updateConstraints, you might never even receive updateConstraints if no one makes a constraint.To fix this chicken and egg problem, override this method to return YES if your view needs the window to use constraint-based layout.
*/
+ (BOOL)requiresConstraintBasedLayoutNS_AVAILABLE_IOS(6_0);
@end
// Separation of Concerns
@interfaceUIView (UIConstraintBasedLayoutLayering)//布局图层
/* Constraints do not actually relate the frames of the views, rather they relate the "alignment rects" of views.This is the same as the frame unless overridden by a subclass of UIView.Alignment rects are the same as the "layout rects" shown in Interface Builder 3.Typically the alignment rect of a view is what the end user would think of as the bounding rect around a control, omitting ornamentation like shadows and engraving lines.The edges of the alignment rect are what is interesting to align, not the shadows and such.
*/
/* These two methods should be inverses of each other.UIKit will call both as part of layout computation.
They may be overridden to provide arbitrary transforms between frame and alignment rect, though the two methods must be inverses of each other.
However, the default implementation uses -alignmentRectInsets, so just override that if it's applicable.It's easier to get right.
A view that displayed an image with some ornament would typically override these, because the ornamental part of an image would scale up with the size of the frame.
Set the NSUserDefault UIViewShowAlignmentRects to YES to see alignment rects drawn.
*/
- (CGRect)alignmentRectForFrame:(CGRect)frameNS_AVAILABLE_IOS(6_0);
- (CGRect)frameForAlignmentRect:(CGRect)alignmentRectNS_AVAILABLE_IOS(6_0);
/* override this if the alignment rect is obtained from the frame by insetting each edge by a fixed amount.This is only called by alignmentRectForFrame: and frameForAlignmentRect:.
*/
- (UIEdgeInsets)alignmentRectInsetsNS_AVAILABLE_IOS(6_0);
- (UIView*)viewForBaselineLayoutNS_DEPRECATED_IOS(6_0,9_0,"Override -viewForFirstBaselineLayout or -viewForLastBaselineLayout as appropriate, instead")__TVOS_PROHIBITED;
/* -viewForFirstBaselineLayout is called by the constraints system when interpreting
the firstBaseline attribute for a view.
For complex custom UIView subclasses, override this method to return the text-based
(i.e., UILabel or non-scrollable UITextView) descendant of the receiver whose first baseline
is appropriate for alignment.
UIView's implementation returns [self viewForLastBaselineLayout], so if the same
descendant is appropriate for both first- and last-baseline layout you may override
just -viewForLastBaselineLayout.
*/
@property(readonly,strong)UIView*viewForFirstBaselineLayoutNS_AVAILABLE_IOS(9_0);
/* -viewForLastBaselineLayout is called by the constraints system when interpreting
the lastBaseline attribute for a view.
For complex custom UIView subclasses, override this method to return the text-based
(i.e., UILabel or non-scrollable UITextView) descendant of the receiver whose last baseline
is appropriate for alignment.
UIView's implementation returns self.
*/
@property(readonly,strong)UIView*viewForLastBaselineLayoutNS_AVAILABLE_IOS(9_0);
/* Override this method to tell the layout system that there is something it doesn't natively understand in this view, and this is how large it intrinsically is.A typical example would be a single line text field.The layout system does not understand text - it must just be told that there's something in the view, and that that something will take a certain amount of space if not clipped.
In response, UIKit will set up constraints that specify (1) that the opaque content should not be compressed or clipped, (2) that the view prefers to hug tightly to its content.
A user of a view may need to specify the priority of these constraints.For example, by default, a push button
-strongly wants to hug its content in the vertical direction (buttons really ought to be their natural height)
-weakly hugs its content horizontally (extra side padding between the title and the edge of the bezel is acceptable)
-strongly resists compressing or clipping content in both directions.
However, you might have a case where you'd prefer to show all the available buttons with truncated text rather than losing some of the buttons. The truncation might only happen in portrait orientation but not in landscape, for example. In that case you'd want to setContentCompressionResistancePriority:forAxis: to (say) UILayoutPriorityDefaultLow for the horizontal axis.
The default 'strong' and 'weak' priorities referred to above are UILayoutPriorityDefaultHigh and UILayoutPriorityDefaultLow.
Note that not all views have an intrinsicContentSize.UIView's default implementation is to return (UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric).The _intrinsic_ content size is concerned only with data that is in the view itself, not in other views. Remember that you can also set constant width or height constraints on any view, and you don't need to override instrinsicContentSize if these dimensions won't be changing with changing view content.
*/
UIKIT_EXTERNconstCGFloatUIViewNoIntrinsicMetricNS_AVAILABLE_IOS(6_0);// -1
- (CGSize)intrinsicContentSizeNS_AVAILABLE_IOS(6_0);
- (void)invalidateIntrinsicContentSizeNS_AVAILABLE_IOS(6_0);// call this when something changes that affects the intrinsicContentSize.Otherwise UIKit won't notice that it changed.
- (UILayoutPriority)contentHuggingPriorityForAxis:(UILayoutConstraintAxis)axisNS_AVAILABLE_IOS(6_0);
- (void)setContentHuggingPriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axisNS_AVAILABLE_IOS(6_0);
- (UILayoutPriority)contentCompressionResistancePriorityForAxis:(UILayoutConstraintAxis)axisNS_AVAILABLE_IOS(6_0);
- (void)setContentCompressionResistancePriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axisNS_AVAILABLE_IOS(6_0);
@end
// Size To Fit
UIKIT_EXTERNconstCGSizeUILayoutFittingCompressedSizeNS_AVAILABLE_IOS(6_0);
UIKIT_EXTERNconstCGSizeUILayoutFittingExpandedSizeNS_AVAILABLE_IOS(6_0);
@interfaceUIView (UIConstraintBasedLayoutFittingSize)//约束基于布局适应尺寸
/* The size fitting most closely to targetSize in which the receiver's subtree can be laid out while optimally satisfying the constraints. If you want the smallest possible size, pass UILayoutFittingCompressedSize; for the largest possible size, pass UILayoutFittingExpandedSize.
Also see the comment for UILayoutPriorityFittingSizeLevel.
*/
- (CGSize)systemLayoutSizeFittingSize:(CGSize)targetSizeNS_AVAILABLE_IOS(6_0);// Equivalent to sending -systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority: with UILayoutPriorityFittingSizeLevel for both priorities.
- (CGSize)systemLayoutSizeFittingSize:(CGSize)targetSize withHorizontalFittingPriority:(UILayoutPriority)horizontalFittingPriority verticalFittingPriority:(UILayoutPriority)verticalFittingPriorityNS_AVAILABLE_IOS(8_0);
@end
@interfaceUIView (UILayoutGuideSupport)//布局指南支持
/* UILayoutGuide objects owned by the receiver.
*/
@property(nonatomic,readonly,copy)NSArray<__kindofUILayoutGuide*> *layoutGuidesNS_AVAILABLE_IOS(9_0);
/* Adds layoutGuide to the receiver, passing the receiver in -setOwningView: to layoutGuide.
*/
- (void)addLayoutGuide:(UILayoutGuide*)layoutGuideNS_AVAILABLE_IOS(9_0);
/* Removes layoutGuide from the receiver, passing nil in -setOwningView: to layoutGuide.
*/
- (void)removeLayoutGuide:(UILayoutGuide*)layoutGuideNS_AVAILABLE_IOS(9_0);
@end
@classNSLayoutXAxisAnchor,NSLayoutYAxisAnchor,NSLayoutDimension;
@interfaceUIView (UIViewLayoutConstraintCreation)
/* Constraint creation conveniences. See NSLayoutAnchor.h for details.
*/
@property(readonly,strong)NSLayoutXAxisAnchor*leadingAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutXAxisAnchor*trailingAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutXAxisAnchor*leftAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutXAxisAnchor*rightAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutYAxisAnchor*topAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutYAxisAnchor*bottomAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutDimension*widthAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutDimension*heightAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutXAxisAnchor*centerXAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutYAxisAnchor*centerYAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutYAxisAnchor*firstBaselineAnchorNS_AVAILABLE_IOS(9_0);
@property(readonly,strong)NSLayoutYAxisAnchor*lastBaselineAnchorNS_AVAILABLE_IOS(9_0);
@end
// Debugging
/* Everything in this section should be used in debugging only, never in shipping code.These methods may not exist in the future - no promises.
*/
@interfaceUIView (UIConstraintBasedLayoutDebugging)布局debug
/* This returns a list of all the constraints that are affecting the current location of the receiver.The constraints do not necessarily involve the receiver, they may affect the frame indirectly.
Pass UILayoutConstraintAxisHorizontal for the constraints affecting [self center].x and CGRectGetWidth([self bounds]), and UILayoutConstraintAxisVertical for the constraints affecting[self center].y and CGRectGetHeight([self bounds]).
*/
- (NSArray<__kindofNSLayoutConstraint*> *)constraintsAffectingLayoutForAxis:(UILayoutConstraintAxis)axisNS_AVAILABLE_IOS(6_0);
/* If there aren't enough constraints in the system to uniquely determine layout, we say the layout is ambiguous.For example, if the only constraint in the system was x = y + 100, then there are lots of different possible values for x and y.This situation is not automatically detected by UIKit, due to performance considerations and details of the algorithm used for layout.
The symptom of ambiguity is that views sometimes jump from place to place, or possibly are just in the wrong place.
-hasAmbiguousLayout runs a check for whether there is another center and bounds the receiver could have that could also satisfy the constraints.
-exerciseAmbiguousLayout does more.It randomly changes the view layout to a different valid layout.Making the UI jump back and forth can be helpful for figuring out where you're missing a constraint.
*/
- (BOOL)hasAmbiguousLayoutNS_AVAILABLE_IOS(6_0);
- (void)exerciseAmbiguityInLayoutNS_AVAILABLE_IOS(6_0);
@end
@interfaceUIView (UIStateRestoration)//状态复位
@property(nullable,nonatomic,copy)NSString*restorationIdentifierNS_AVAILABLE_IOS(6_0);
- (void) encodeRestorableStateWithCoder:(NSCoder*)coderNS_AVAILABLE_IOS(6_0);
- (void) decodeRestorableStateWithCoder:(NSCoder*)coderNS_AVAILABLE_IOS(6_0);
@end
@interfaceUIView (UISnapshotting)
/*
* When requesting a snapshot, 'afterUpdates' defines whether the snapshot is representative of what's currently on screen or if you wish to include any recent changes before taking the snapshot.
If called during layout from a committing transaction, snapshots occurring after the screen updates will include all changes made, regardless of when the snapshot is taken and the changes are made. For example:
- (void)layoutSubviews {
UIView *snapshot = [self snapshotViewAfterScreenUpdates:YES];
self.alpha = 0.0;
}
The snapshot will appear to be empty since the change in alpha will be captured by the snapshot. If you need to animate the view during layout, animate the snapshot instead.
* Creating snapshots from existing snapshots (as a method to duplicate, crop or create a resizable variant) is supported. In cases where many snapshots are needed, creating a snapshot from a common superview and making subsequent snapshots from it can be more performant. Please keep in mind that if 'afterUpdates' is YES, the original snapshot is committed and any changes made to it, not the view originally snapshotted, will be included.
*/
- (UIView*)snapshotViewAfterScreenUpdates:(BOOL)afterUpdatesNS_AVAILABLE_IOS(7_0);
- (UIView*)resizableSnapshotViewFromRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates withCapInsets:(UIEdgeInsets)capInsetsNS_AVAILABLE_IOS(7_0);// Resizable snapshots will default to stretching the center
// Use this method to render a snapshot of the view hierarchy into the current context. Returns NO if the snapshot is missing image data, YES if the snapshot is complete. Calling this method from layoutSubviews while the current transaction is committing will capture what is currently displayed regardless if afterUpdates is YES.
- (BOOL)drawViewHierarchyInRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdatesNS_AVAILABLE_IOS(7_0);
@end
NS_ASSUME_NONNULL_END