UIView类定义了屏幕上一个矩形区域,在iOS中几乎所有的可视化控件都是UIView的子类,它还负责视图的内容管理、子视图管理、事件处理、动画实现等
@protocol UICoordinateSpace <NSObject>
// 将当前的坐标空间点转换到指定的坐标空间
- (CGPoint)convertPoint:(CGPoint)point toCoordinateSpace:(id <UICoordinateSpace>)coordinateSpace NS_AVAILABLE_IOS(8_0);
// 将指定的坐标空间点转换到当前的坐标空间
- (CGPoint)convertPoint:(CGPoint)point fromCoordinateSpace:(id <UICoordinateSpace>)coordinateSpace NS_AVAILABLE_IOS(8_0);
// 将当前的矩形坐标空间转换到指定的矩形坐标空间
- (CGRect)convertRect:(CGRect)rect toCoordinateSpace:(id <UICoordinateSpace>)coordinateSpace NS_AVAILABLE_IOS(8_0);
// 将指定的矩形坐标空间转换到当前的矩形坐标空间
- (CGRect)convertRect:(CGRect)rect fromCoordinateSpace:(id <UICoordinateSpace>)coordinateSpace NS_AVAILABLE_IOS(8_0);
// 该view在本地坐标系统中的位置和大小(参照点是,本地坐标系统)
@property (readonly, nonatomic) CGRect bounds NS_AVAILABLE_IOS(8_0);
@end
// 视图的基础图层
#if UIKIT_DEFINE_AS_PROPERTIES
@property(class, nonatomic, readonly) Class layerClass;
#else
+ (Class)layerClass;
#endif
// 初始化视图并设置位置和大小
- (instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER;
// 用于xib初始化
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
// 是否可以交互
@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled; // default is YES.
// 当前视图标签
@property(nonatomic) NSInteger tag; // default is 0
// 用于视图渲染的核心动画层
@property(nonatomic,readonly,strong) CALayer *layer;
#if UIKIT_DEFINE_AS_PROPERTIES
// 视图是否可以被聚集(返回YES可能是:视图被隐藏、透明度为0,userInteractionEnabled设置为NO等)
@property(nonatomic,readonly) BOOL canBecomeFocused NS_AVAILABLE_IOS(9_0); // NO by default
#else
- (BOOL)canBecomeFocused NS_AVAILABLE_IOS(9_0); // NO by default
#endif
// 当前项是否可以被聚焦
@property (readonly, nonatomic, getter=isFocused) BOOL focused NS_AVAILABLE_IOS(9_0);
// 左右滑动翻转效果
@property (nonatomic) UISemanticContentAttribute semanticContentAttribute NS_AVAILABLE_IOS(9_0);
// 返回界面的方向
+ (UIUserInterfaceLayoutDirection)userInterfaceLayoutDirectionForSemanticContentAttribute:(UISemanticContentAttribute)attribute NS_AVAILABLE_IOS(9_0);
// 返回相对于指定视图的界面方向
+(UIUserInterfaceLayoutDirection)userInterfaceLayoutDirectionForSemanticContentAttribute:(UISemanticContentAttribute)semanticContentAttribute relativeToLayoutDirection:(UIUserInterfaceLayoutDirection)layoutDirection NS_AVAILABLE_IOS(10_0);
// 安排即时内容的布局的方向
@property (readonly, nonatomic) UIUserInterfaceLayoutDirection effectiveUserInterfaceLayoutDirection NS_AVAILABLE_IOS(10_0);
@end
@interface UIView(UIViewGeometry)
// 父视图位置(参照点是,父view坐标系统)
@property(nonatomic) CGRect frame;
// 该view在本地坐标系统中的位置和大小(参照点是,本地坐标系统)
@property(nonatomic) CGRect bounds;
// frame中的中心点(决定当前视图是否是处理触摸事件的唯一对象)
@property(nonatomic) CGPoint center;
// 视图变换
@property(nonatomic) CGAffineTransform transform;
// 视图内容的缩放比例
@property(nonatomic) CGFloat contentScaleFactor NS_AVAILABLE_IOS(4_0);
// 支持多点触控
@property(nonatomic,getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled __TVOS_PROHIBITED; // default is NO
// 决定当前视图是否处理出门事件的唯一对象
@property(nonatomic,getter=isExclusiveTouch) BOOL exclusiveTouch __TVOS_PROHIBITED; // default is NO
// 在指定点上点击测试指定事件
- (nullable UIView *)hitTest:(CGPoint)point withEvent:(nullable UIEvent *)event;
// 测试指定的点是否包含在接收对象中
- (BOOL)pointInside:(CGPoint)point withEvent:(nullable UIEvent *)event; // default returns YES if point is in bounds
// 转换视图间坐标
// 转换一个点从接受对象的坐标系到指定视图
- (CGPoint)convertPoint:(CGPoint)point toView:(nullable UIView *)view;
// 与上面相反,指定视图坐标中的一个点转换为接收对象
- (CGPoint)convertPoint:(CGPoint)point fromView:(nullable UIView *)view;
// 将当前的矩形坐标空间转换到指定的矩形坐标空间
- (CGRect)convertRect:(CGRect)rect toView:(nullable UIView *)view;
// 将指定的矩形坐标空间转换到当前的矩形坐标空间
- (CGRect)convertRect:(CGRect)rect fromView:(nullable UIView *)view;
// 自动尺寸调整
@property(nonatomic) BOOL autoresizesSubviews; // default is YES. if set, subviews are adjusted according to their autoresizingMask if self.bounds changes
// 自动调整子控件与父控件中间的位置,宽高
@property(nonatomic) UIViewAutoresizing autoresizingMask;
// 计算并返回的大小最适合它的子视图的视图。(让视图计算最适合子视图的大小,即能把全部子视图显示出来所需要的最小的size)
- (CGSize)sizeThatFits:(CGSize)size;
// 得到最适合当前包含它子视图的尺寸
- (void)sizeToFit;
@end
@interface UIView(UIViewHierarchy)
// 当前视图的父视图
@property(nullable, nonatomic,readonly) UIView *superview;
// 当前视图的所有子视图
@property(nonatomic,readonly,copy) NSArray<__kindof UIView *> *subviews;
// 当前视图上的UIWindow
@property(nullable, nonatomic,readonly) UIWindow *window;
// 从父视图中移除
- (void)removeFromSuperview;
// 在指定的位置插入子视图,视图的所有视图其实组成了一个数组
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
// 交换两子视图的位置
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;
// 添加视图
- (void)addSubview:(UIView *)view;
// 将指定的子视图移动到指定siblingSubview子视图的后面
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
// 将指定的子视图移动到指定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:(nullable UIView *)newSuperview;
// 通知视图已经移动到一个新的父视图中
- (void)didMoveToSuperview;
// 通知视图将要移动到一个新的window中
- (void)willMoveToWindow:(nullable UIWindow *)newWindow;
// 通知视图已经移动到一个新的window中
- (void)didMoveToWindow;
// 判断接收对象是否是指定视图的子视图,或与指定视图是同一视图
- (BOOL)isDescendantOfView:(UIView *)view; // returns YES for self.
// 返回指定标签匹配到的视图
- (nullable __kindof UIView *)viewWithTag:(NSInteger)tag; // recursive search. includes self
// 标记为需要重新布局,异步调用layoutIfNeeded刷新布局,不立即刷新,但layoutSubviews一定会被调用
- (void)setNeedsLayout;
// 如果有需要刷新的标记,立即调用layoutSubviews进行布局(如果没有标记,不会调用layoutSubviews)
- (void)layoutIfNeeded;
// 将子类重新布局
- (void)layoutSubviews;
// 设置视图的间距
@property (nonatomic) UIEdgeInsets layoutMargins NS_AVAILABLE_IOS(8_0);
// 是否将当前视图的间距和父视图相同
@property (nonatomic) BOOL preservesSuperviewLayoutMargins NS_AVAILABLE_IOS(8_0); // default is NO
// 通知布局发生变化
- (void)layoutMarginsDidChange NS_AVAILABLE_IOS(8_0);
// 视图间距引导
@property(readonly,strong) UILayoutGuide *layoutMarginsGuide NS_AVAILABLE_IOS(9_0);
/// 获取此区域的内的布局引导
@property (nonatomic, readonly, strong) UILayoutGuide *readableContentGuide NS_AVAILABLE_IOS(9_0);
@end
@interface UIView(UIViewRendering)
// 在指定的区域绘画视图
- (void)drawRect:(CGRect)rect;
// 标记整个视图的边界矩形需要重绘
- (void)setNeedsDisplay;
// 标记在指定区域内的视图的边界需要重绘
- (void)setNeedsDisplayInRect:(CGRect)rect;
// 决定子视图是否被限定在当前视图的bounds中
@property(nonatomic) BOOL clipsToBounds; //Default is NO.
// 背景色
@property(nullable, nonatomic,copy) UIColor *backgroundColor UI_APPEARANCE_SELECTOR;
// 透明度
@property(nonatomic) CGFloat alpha; // animatable. default is 1.0
// 不透明度
@property(nonatomic,getter=isOpaque) BOOL opaque; // default is YES.
// 决定在视图重画之前是否先清理视图以前的内容
@property(nonatomic) BOOL clearsContextBeforeDrawing; // default is YES.
// 是否隐藏视图
@property(nonatomic,getter=isHidden) BOOL hidden; // default is NO.
// 视图内容风格
@property(nonatomic) UIViewContentMode contentMode; // default is UIViewContentModeScaleToFill
// 一个可选视图,用于屏蔽视图内容
@property(nullable, nonatomic,strong) UIView *maskView NS_AVAILABLE_IOS(8_0);
// 最底部视图色彩
@property(null_resettable, nonatomic, strong) UIColor *tintColor NS_AVAILABLE_IOS(7_0);
// 色彩调整风格
@property(nonatomic) UIViewTintAdjustmentMode tintAdjustmentMode NS_AVAILABLE_IOS(7_0);
// 告诉系统tintColor值将会改变
- (void)tintColorDidChange NS_AVAILABLE_IOS(7_0);
@end
@interface UIView(UIViewAnimation)
// 标记开始/提交动画块的开始
+ (void)beginAnimations:(nullable NSString *)animationID context:(nullable void *)context;
// 标记开始/提交动画块的结束,并为执行调度动画
+ (void)commitAnimations;
// 设置动画消息的委托
+ (void)setAnimationDelegate:(nullable id)delegate; // default = nil
// 设置动画启动时发送给动画委托的消息
+ (void)setAnimationWillStartSelector:(nullable SEL)selector; // default = NULL. -animationWillStart:(NSString *)animationID context:(void *)context
// 设置动画停止时发送给动画委托的消息
+ (void)setAnimationDidStopSelector:(nullable SEL)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.
// 设置动画是否反转执行
+ (void)setAnimationRepeatAutoreverses:(BOOL)repeatAutoreverses; // default = NO.
// 设置动画是否从当前状态开始播放
+ (void)setAnimationBeginsFromCurrentState:(BOOL)fromCurrentState; // default = NO.
// 设置到指定视图的过渡动画
+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache;
// 设置是否启用了动画
+ (void)setAnimationsEnabled:(BOOL)enabled;
// 是否启用了动画
#if UIKIT_DEFINE_AS_PROPERTIES
@property(class, nonatomic, readonly) BOOL areAnimationsEnabled;
#else
+ (BOOL)areAnimationsEnabled;
#endif
// 禁用视图的过渡动画
+ (void)performWithoutAnimation:(void (NS_NOESCAPE ^)(void))actionsWithoutAnimation NS_AVAILABLE_IOS(7_0);
// 当前动画的持续时间
#if UIKIT_DEFINE_AS_PROPERTIES
@property(class, nonatomic, readonly) NSTimeInterval inheritedAnimationDuration NS_AVAILABLE_IOS(9_0);
#else
+ (NSTimeInterval)inheritedAnimationDuration NS_AVAILABLE_IOS(9_0);
#endif
@end
@interface UIView(UIViewAnimationWithBlocks)
// 用于对一个或多个视图的改变的持续时间、延时、选项动画完成时的操作
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);
// 用于对一个或多个视图的改变的持续时间、选项动画完成时的操作
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0
// 用于对一个或多个视图的改变的持续时间内动画完成时的操作
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations NS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0, completion = NULL
// 使用与物理弹簧运动相对应的定时曲线执行视图动画
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);
// 为指定的容器视图创建转换动画
+ (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);
// 使用给定的参数在指定视图之间创建转换动画
+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);
// 在一个或多个视图上执行指定的系统提供的动画,以及定义的可选并行动画.
+ (void)performSystemAnimation:(UISystemAnimation)animation onViews:(NSArray<__kindof UIView *> *)views options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))parallelAnimations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);
@end
@interface UIView (UIViewKeyframeAnimations)
// 创建一个动画块对象,可用于为当前视图设置基于关键帧的动画
+ (void)animateKeyframesWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);
// 添加指定开始时间、持续时间的关键帧动画
+ (void)addKeyframeWithRelativeStartTime:(double)frameStartTime relativeDuration:(double)frameDuration animations:(void (^)(void))animations NS_AVAILABLE_IOS(7_0);
@end
@interface UIView (UIViewGestureRecognizers)
// 当前视图所附加的手势识别器
@property(nullable, nonatomic,copy) NSArray<__kindof UIGestureRecognizer *> *gestureRecognizers NS_AVAILABLE_IOS(3_2);
// 为视图添加一个手势识别器
- (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer NS_AVAILABLE_IOS(3_2);
// 删除视图上的一个手势识别器
- (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer NS_AVAILABLE_IOS(3_2);
// 开始一个手势识别器
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer NS_AVAILABLE_IOS(6_0);
@end
@interface UIView (UIViewMotionEffects)
// 开始向视图中添加运动效果
- (void)addMotionEffect:(UIMotionEffect *)effect NS_AVAILABLE_IOS(7_0);
// 删除视图中的运动效果
- (void)removeMotionEffect:(UIMotionEffect *)effect NS_AVAILABLE_IOS(7_0);
// 视图中运动效果的数组
@property (copy, nonatomic) NSArray<__kindof UIMotionEffect *> *motionEffects NS_AVAILABLE_IOS(7_0);
@end
@interface UIView (UIConstraintBasedLayoutInstallingConstraints)
// 视图所持有的约束
@property(nonatomic,readonly) NSArray<__kindof NSLayoutConstraint *> *constraints NS_AVAILABLE_IOS(6_0);
// 添加一个约束
- (void)addConstraint:(NSLayoutConstraint *)constraint NS_AVAILABLE_IOS(6_0);
// 添加多个约束
- (void)addConstraints:(NSArray<__kindof NSLayoutConstraint *> *)constraints NS_AVAILABLE_IOS(6_0);
// 移除视图上指定的约束
- (void)removeConstraint:(NSLayoutConstraint *)constraint NS_AVAILABLE_IOS(6_0);
// 移除指定的一组约束
- (void)removeConstraints:(NSArray<__kindof NSLayoutConstraint *> *)constraints NS_AVAILABLE_IOS(6_0);
@end
@interface UIView (UIConstraintBasedLayoutCoreMethods)
// 更新视图和其子视图的约束
- (void)updateConstraintsIfNeeded NS_AVAILABLE_IOS(6_0);
// 为视图更新约束
- (void)updateConstraints NS_AVAILABLE_IOS(6_0) NS_REQUIRES_SUPER;
// 视图的约束是否需要更新
- (BOOL)needsUpdateConstraints NS_AVAILABLE_IOS(6_0);
// 设置视图的约束需要更新
- (void)setNeedsUpdateConstraints NS_AVAILABLE_IOS(6_0);
@end
@interface UIView (UIConstraintBasedCompatibility)
// 是否自动尺寸转换为自动布局
@property(nonatomic) BOOL translatesAutoresizingMaskIntoConstraints NS_AVAILABLE_IOS(6_0); // Default YES
// 视图是否一来与基础自动布局的约束
#if UIKIT_DEFINE_AS_PROPERTIES
@property(class, nonatomic, readonly) BOOL requiresConstraintBasedLayout NS_AVAILABLE_IOS(6_0);
#else
+ (BOOL)requiresConstraintBasedLayout NS_AVAILABLE_IOS(6_0);
#endif
@end
@interface UIView (UIConstraintBasedLayoutLayering)
// 返回给定框架的视图的对齐矩阵
- (CGRect)alignmentRectForFrame:(CGRect)frame NS_AVAILABLE_IOS(6_0);
// 返回给定对齐矩形的视图的frame
- (CGRect)frameForAlignmentRect:(CGRect)alignmentRect NS_AVAILABLE_IOS(6_0);
// 返回从视图的frame上定义的对齐矩阵的边框
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) UIEdgeInsets alignmentRectInsets NS_AVAILABLE_IOS(6_0);
#else
- (UIEdgeInsets)alignmentRectInsets NS_AVAILABLE_IOS(6_0);
#endif
// 返回满足基线约束条件的视图
- (UIView *)viewForBaselineLayout NS_DEPRECATED_IOS(6_0, 9_0, "Override -viewForFirstBaselineLayout or -viewForLastBaselineLayout as appropriate, instead") __TVOS_PROHIBITED;
// 返回用于满足第一基线约束的视图
@property(readonly,strong) UIView *viewForFirstBaselineLayout NS_AVAILABLE_IOS(9_0);
// 返回用于满足上次基线约束的视图
@property(readonly,strong) UIView *viewForLastBaselineLayout NS_AVAILABLE_IOS(9_0);
UIKIT_EXTERN const CGFloat UIViewNoIntrinsicMetric NS_AVAILABLE_IOS(6_0); // -1
// 返回接收对象的原本大小
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) CGSize intrinsicContentSize NS_AVAILABLE_IOS(6_0);
#else
- (CGSize)intrinsicContentSize NS_AVAILABLE_IOS(6_0);
#endif
// 废除视图原本内容的size
- (void)invalidateIntrinsicContentSize NS_AVAILABLE_IOS(6_0);
// 设置当视图要变大时,视图的压缩改变方式,返回一个优先权(确定view有多大的优先级阻止自己变大)
- (UILayoutPriority)contentHuggingPriorityForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
// 设置放先权
- (void)setContentHuggingPriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
// 设置当视图要变小时,视图的压缩改变方式,是水平缩小还是垂直缩小,并返回一个优先权(确定有多大的优先级阻止自己变小)
- (UILayoutPriority)contentCompressionResistancePriorityForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
// 设置优先权
- (void)setContentCompressionResistancePriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
@end
// Size To Fit
UIKIT_EXTERN const CGSize UILayoutFittingCompressedSize NS_AVAILABLE_IOS(6_0);
UIKIT_EXTERN const CGSize UILayoutFittingExpandedSize NS_AVAILABLE_IOS(6_0);
@interface UIView (UIConstraintBasedLayoutFittingSize)
// 返回满足持有约束的视图的size
- (CGSize)systemLayoutSizeFittingSize:(CGSize)targetSize NS_AVAILABLE_IOS(6_0);
// 返回满足它所包含的约束的视图的大小
- (CGSize)systemLayoutSizeFittingSize:(CGSize)targetSize withHorizontalFittingPriority:(UILayoutPriority)horizontalFittingPriority verticalFittingPriority:(UILayoutPriority)verticalFittingPriority NS_AVAILABLE_IOS(8_0);
@end
@interface UIView (UILayoutGuideSupport)
// 此视图拥有布局向导对象的数组
@property(nonatomic,readonly,copy) NSArray<__kindof UILayoutGuide *> *layoutGuides NS_AVAILABLE_IOS(9_0);
// 向视图中添加布局向导
- (void)addLayoutGuide:(UILayoutGuide *)layoutGuide NS_AVAILABLE_IOS(9_0);
// 移除视图中的布局向导
- (void)removeLayoutGuide:(UILayoutGuide *)layoutGuide NS_AVAILABLE_IOS(9_0);
@end
@class NSLayoutXAxisAnchor,NSLayoutYAxisAnchor,NSLayoutDimension;
@interface UIView (UIViewLayoutConstraintCreation)
// 布局视图的前缘框的布局锚点
@property(readonly, strong) NSLayoutXAxisAnchor *leadingAnchor NS_AVAILABLE_IOS(9_0);
// 布局视图的后缘边框的布局锚点
@property(readonly, strong) NSLayoutXAxisAnchor *trailingAnchor NS_AVAILABLE_IOS(9_0);
// 布局视图的左边框的布局锚点
@property(readonly, strong) NSLayoutXAxisAnchor *leftAnchor NS_AVAILABLE_IOS(9_0);
// 布局视图的右边框的布局锚点
@property(readonly, strong) NSLayoutXAxisAnchor *rightAnchor NS_AVAILABLE_IOS(9_0);
// 布局视图的顶边框的布局锚点
@property(readonly, strong) NSLayoutYAxisAnchor *topAnchor NS_AVAILABLE_IOS(9_0);
// 布局视图的底边框的布局锚点
@property(readonly, strong) NSLayoutYAxisAnchor *bottomAnchor NS_AVAILABLE_IOS(9_0);
// 布局视图的宽度
@property(readonly, strong) NSLayoutDimension *widthAnchor NS_AVAILABLE_IOS(9_0);
// 布局视图的高度
@property(readonly, strong) NSLayoutDimension *heightAnchor NS_AVAILABLE_IOS(9_0);
// 布局视图的水平中心轴
@property(readonly, strong) NSLayoutXAxisAnchor *centerXAnchor NS_AVAILABLE_IOS(9_0);
// 布局视图的垂直中心轴
@property(readonly, strong) NSLayoutYAxisAnchor *centerYAnchor NS_AVAILABLE_IOS(9_0);
// 一个代表对视图中的文本的最高线基线布置锚
@property(readonly, strong) NSLayoutYAxisAnchor *firstBaselineAnchor NS_AVAILABLE_IOS(9_0);
// 一个代表对视图中的文本的最低线基线布置锚
@property(readonly, strong) NSLayoutYAxisAnchor *lastBaselineAnchor NS_AVAILABLE_IOS(9_0);
@end
@interface UIView (UIConstraintBasedLayoutDebugging)
// 返回影响一个给定轴视图布局的约束
- (NSArray<__kindof NSLayoutConstraint *> *)constraintsAffectingLayoutForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
// 视图的位置是否不完全指定
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) BOOL hasAmbiguousLayout NS_AVAILABLE_IOS(6_0);
#else
- (BOOL)hasAmbiguousLayout NS_AVAILABLE_IOS(6_0);
#endif
// 在不同的有效值之间用一个模糊的布局随机改变视图的frame
- (void)exerciseAmbiguityInLayout NS_AVAILABLE_IOS(6_0);
@end
@interface UILayoutGuide (UIConstraintBasedLayoutDebugging)
// 返回对给定轴影响视图布局的约束
- (NSArray<__kindof NSLayoutConstraint *> *)constraintsAffectingLayoutForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(10_0);
// 确定影响视图布局的约束是否完全指定视图的位置
#if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) BOOL hasAmbiguousLayout NS_AVAILABLE_IOS(10_0);
#else
- (BOOL)hasAmbiguousLayout NS_AVAILABLE_IOS(10_0);
#endif
@end
@interface UIView (UIStateRestoration)
// 该标示符决定该视图是否支持恢复状态
@property (nullable, nonatomic, copy) NSString *restorationIdentifier NS_AVAILABLE_IOS(6_0);
// 编码视图的状态信息
- (void) encodeRestorableStateWithCoder:(NSCoder *)coder NS_AVAILABLE_IOS(6_0);
// 解码一个视图状态信息
- (void) decodeRestorableStateWithCoder:(NSCoder *)coder NS_AVAILABLE_IOS(6_0);
@end
@interface UIView (UISnapshotting)
// 根据当前视图的内容返回快照视图
- (nullable UIView *)snapshotViewAfterScreenUpdates:(BOOL)afterUpdates NS_AVAILABLE_IOS(7_0);
// 返回一个基于当前视图指定内容的快照视图,可插入
- (nullable UIView *)resizableSnapshotViewFromRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates withCapInsets:(UIEdgeInsets)capInsets NS_AVAILABLE_IOS(7_0);
// 呈现一个快照的完整视图层次可见屏幕为当前上下文
- (BOOL)drawViewHierarchyInRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates NS_AVAILABLE_IOS(7_0);
@end
// 动画效果
typedef NS_ENUM(NSInteger, UIViewAnimationCurve) {
UIViewAnimationCurveEaseInOut, // 淡入淡出
UIViewAnimationCurveEaseIn, // 淡入
UIViewAnimationCurveEaseOut, // 淡出
UIViewAnimationCurveLinear,
};
// 视图内容风格
typedef NS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeScaleToFill, // 缩放内容到合适比例大小
UIViewContentModeScaleAspectFit, // 缩放内容到合适的大小,边界多余部分透明
UIViewContentModeScaleAspectFill, // 缩放内容填充到指定大小,边界多余的部分省略.
UIViewContentModeRedraw, // 重绘视图边界 (需调用 -setNeedsDisplay)
UIViewContentModeCenter, // 视图保持等比缩放
UIViewContentModeTop, // 视图顶部对齐
UIViewContentModeBottom, // 视图底部对齐
UIViewContentModeLeft, // 视图左侧对齐
UIViewContentModeRight, // 视图右侧对齐
UIViewContentModeTopLeft, // 视图左上角对齐
UIViewContentModeTopRight, // 视图右上角对齐
UIViewContentModeBottomLeft, // 视图左下角对齐
UIViewContentModeBottomRight, // 视图右下角对齐
};
// 过渡动画
typedef NS_ENUM(NSInteger, UIViewAnimationTransition) {
UIViewAnimationTransitionNone, // 无
UIViewAnimationTransitionFlipFromLeft, // 沿视图垂直中心轴左到右移动
UIViewAnimationTransitionFlipFromRight, // 沿视图垂直中心轴右到左移动
UIViewAnimationTransitionCurlUp, // 由底部向上卷起
UIViewAnimationTransitionCurlDown, // 由顶部向下展开
};
// 视图布局
typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
UIViewAutoresizingNone = 0, // 无
UIViewAutoresizingFlexibleLeftMargin = 1 << 0, // 调整扩大或缩小左边间距
UIViewAutoresizingFlexibleWidth = 1 << 1, // 调整宽度
UIViewAutoresizingFlexibleRightMargin = 1 << 2, // 调整扩大或缩小右边间距
UIViewAutoresizingFlexibleTopMargin = 1 << 3, // 调整视图顶部间距
UIViewAutoresizingFlexibleHeight = 1 << 4, // 调整高度
UIViewAutoresizingFlexibleBottomMargin = 1 << 5 // 调整视图底部间距
};
// 动画选项
typedef NS_OPTIONS(NSUInteger, UIViewAnimationOptions) {
UIViewAnimationOptionLayoutSubviews = 1 << 0, // 子视图在指定的时间内完成在父视图上的自动
UIViewAnimationOptionAllowUserInteraction = 1 << 1, // 开启交互动画
UIViewAnimationOptionBeginFromCurrentState = 1 << 2, // 从当前值开始动画
UIViewAnimationOptionRepeat = 1 << 3, // 无限重复
UIViewAnimationOptionAutoreverse = 1 << 4, // 自动来回
UIViewAnimationOptionOverrideInheritedDuration = 1 << 5, // 忽略嵌套的动画的时间
UIViewAnimationOptionOverrideInheritedCurve = 1 << 6, // 忽略嵌套的路径动画
UIViewAnimationOptionAllowAnimatedContent = 1 << 7, // 只执行过渡动画
UIViewAnimationOptionShowHideTransitionViews = 1 << 8, // 隐藏或展示过渡动画视图
UIViewAnimationOptionOverrideInheritedOptions = 1 << 9, // 不继承任何动画类型
// 同上
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);
// 关键帧动画
typedef NS_OPTIONS(NSUInteger, UIViewKeyframeAnimationOptions) {
UIViewKeyframeAnimationOptionLayoutSubviews = UIViewAnimationOptionLayoutSubviews, // 子视图在指定的时间内完成在父视图上的自动布局的动画
UIViewKeyframeAnimationOptionAllowUserInteraction = UIViewAnimationOptionAllowUserInteraction, // 开启交互动画
UIViewKeyframeAnimationOptionBeginFromCurrentState = UIViewAnimationOptionBeginFromCurrentState, // 从当前值开始动画
UIViewKeyframeAnimationOptionRepeat = UIViewAnimationOptionRepeat, // 无限重复
UIViewKeyframeAnimationOptionAutoreverse = UIViewAnimationOptionAutoreverse, // 自动来回
UIViewKeyframeAnimationOptionOverrideInheritedDuration = UIViewAnimationOptionOverrideInheritedDuration, // 忽略嵌套的动画的时间
UIViewKeyframeAnimationOptionOverrideInheritedOptions = UIViewAnimationOptionOverrideInheritedOptions, // 不继承任何动画类型
UIViewKeyframeAnimationOptionCalculationModeLinear = 0 << 10, // default
UIViewKeyframeAnimationOptionCalculationModeDiscrete = 1 << 10,
UIViewKeyframeAnimationOptionCalculationModePaced = 2 << 10,
UIViewKeyframeAnimationOptionCalculationModeCubic = 3 << 10,
UIViewKeyframeAnimationOptionCalculationModeCubicPaced = 4 << 10
} NS_ENUM_AVAILABLE_IOS(7_0);
typedef NS_ENUM(NSUInteger, UISystemAnimation) {
UISystemAnimationDelete, // 完成时从视图中删除
} NS_ENUM_AVAILABLE_IOS(7_0);
// 色彩调整风格
typedef NS_ENUM(NSInteger, UIViewTintAdjustmentMode) {
UIViewTintAdjustmentModeAutomatic, // 与父视图相同
UIViewTintAdjustmentModeNormal, // 未经修改的
UIViewTintAdjustmentModeDimmed, // 饱和、暗淡的原始色
} NS_ENUM_AVAILABLE_IOS(7_0);
// 左右切换或左右布局
typedef NS_ENUM(NSInteger, UISemanticContentAttribute) {
UISemanticContentAttributeUnspecified = 0, // 左右切换时视图翻转
UISemanticContentAttributePlayback, // 音乐播放按钮设置,左右切换此视图不会翻转
UISemanticContentAttributeSpatial, // 控件方向不能改变
UISemanticContentAttributeForceLeftToRight, // 从左到右布局
UISemanticContentAttributeForceRightToLeft // 从右到左布局
} NS_ENUM_AVAILABLE_IOS(9_0);
// 约束布局中心线类型
typedef NS_ENUM(NSInteger, UILayoutConstraintAxis) {
UILayoutConstraintAxisHorizontal = 0, // 以水平线为中心
UILayoutConstraintAxisVertical = 1 // 以垂直线为中心
};
网友评论