约束的属性和方法

非原创~

Initializing a ViewObject //初始化view

- (id)initWithFrame:(CGRect)aRect //通过一个矩形对象初始化

Configuring a View’sVisual Appearance //配置视觉展示

@property(nonatomic, copy) UIColor *backgroundColor//设置背景色
@property(nonatomic,getter=isHidden) BOOL hidden //隐藏view,默认为NO
@property(nonatomic) CGFloat alpha //设置透明度,0.0至1.0区间
@property(nonatomic, getter=isOpaque) BOOL opaque//告诉系统渲染器view是否不透明,设置YES可以加快渲染,默认为YES,如果设置了alpha值,应该设置为NO
@property(nonatomic) BOOL clipsToBounds//是否裁剪超出边界的视图,与css中overflow类似,默认为NO
@property(nonatomic) BOOL clearsContextBeforeDrawing//是否清除缓冲区中不可见内容,默认为YES,如果在一个滚动操作频繁的视图中,应该设为NO,以避免重新渲染,提升性能
+ (Class)layerClass//可以返回主layer所使用的类,UIView的子类可以通过重载这个方法,来让UIView使用不同的CALayer来显示
@property(nonatomic, readonly, retain) CALayer *layer //返回CoreAnimation层所使用的渲染方式

Configuring theEvent-Related Behavior //配置事件关系

@property(nonatomic, getter=isUserInteractionEnabled) BOOLuserInteractionEnabled//设置view是否响应用户事件,如touch、keyboard,默认为YES
@property(nonatomic, getter=isMultipleTouchEnabled) BOOLmultipleTouchEnabled //设置view是否响应多点触摸,默认为NO
@property(nonatomic, getter=isExclusiveTouch) BOOL exclusiveTouch//设置touch是否排它,默认为NO

Configuring theBounds and Frame Rectangles //配置边界和矩形框架

@property(nonatomic) CGRect frame //设置view框架
@property(nonatomic) CGRect bounds //设置view边界
@property(nonatomic) CGPoint center //设置中心点
@property(nonatomic) CGAffineTransform transform//设置transform,与css类似,CGAffineTransform是个矩阵结构体

Managingthe View Hierarchy //管理视图层级

@property(nonatomic, readonly) UIView *superview//返回父view,只读
@property(nonatomic, readonly, copy) NSArray *subviews//返回子view集合,只读
@property(nonatomic, readonly) UIWindow *window//返回window对象,只读
- (void)addSubview:(UIView *)view //添加一个子view到view中
- (void)bringSubviewToFront:(UIView *)view//把一个子view位置移动到列表最前
- (void)sendSubviewToBack:(UIView *)view//把一个子view位置向后移动一格
-(void)removeFromSuperview //把调用该方法的view从其父view中移除
- (void)insertSubview:(UIView*)view atIndex:(NSInteger)index //插入一个子view到指定索引,从0开始
- (void)insertSubview:(UIView *)view aboveSubview:(UIView*)siblingSubview //插入一个子view到指定view之前
- (void)insertSubview:(UIView *)view belowSubview:(UIView*)siblingSubview //插入一个子view到指定view之后
- (void)exchangeSubviewAtIndex:(NSInteger)index1withSubviewAtIndex:(NSInteger)index2 //交换两个view的索引
- (BOOL)isDescendantOfView:(UIView *)view //判断是不是指定元素的子节点或是其本身

Configuring theResizing Behavior //配置尺寸改变行为

@property(nonatomic) UIViewAutoresizing autoresizingMask//当父元素窗口尺寸改变时,子节点如何去自适应变化
@property(nonatomic) BOOL autoresizesSubviews//子view是否自适应变化,默认为YES
@property(nonatomic) UIViewContentMode contentMode//view自适应变化的方式
- (CGSize)sizeThatFits:(CGSize)size//传递view的尺寸,返回建议的子view尺寸
- (void)sizeToFit //调整view的尺寸去适应其内容

Layingout Subviews //布局子节点

- (void)layoutSubviews //布局子view
- (void)setNeedsLayout //在下次更新中刷新布局
- (void)layoutIfNeeded //立即刷新布局

Opting into Constraint-Based Layout //选择约束布局的方式

+ (BOOL)requiresConstraintBasedLayout//返回view是否是约束布局模式,ios6
-(BOOL)translatesAutoresizingMaskIntoConstraints//返回一个BOOL,判断自动布局是否可为转换约束布局,ios6
- (void)setTranslatesAutoresizingMaskIntoConstraints:(BOOL)flag//设置在约束布局系统中是否把自动布局转换为约束布局,ios6

ManagingConstraints //约束管理

- (NSArray *)constraints //返回view的约束句柄,ios6
- (void)addConstraint:(NSLayoutConstraint *)constraint//添加约束句柄,ios6
- (void)addConstraints:(NSArray *)constraints//添加约束句柄数组,ios6
- (void)removeConstraint:(NSLayoutConstraint *)constraint//删除约束句柄,ios6
- (void)removeConstraints:(NSArray *)constraints//删除约束句柄数组,ios6

Measuringin Constraint-Based Layout //测量约束布局

- (CGSize)systemLayoutSizeFittingSize:(CGSize)targetSize//返回最合适的尺寸,ios6
- (CGSize)intrinsicContentSize //返回view的自然尺寸,ios6
- (void)invalidateIntrinsicContentSize //使内容尺寸无效化,ios6
-(UILayoutPriority)contentCompressionResistancePriorityForAxis:(UILayoutConstraintAxis)axis//待补充,ios6
-(void)setContentCompressionResistancePriority:(UILayoutPriority)priorityforAxis:(UILayoutConstraintAxis)axis //待补充,ios6
-(UILayoutPriority)contentHuggingPriorityForAxis:(UILayoutConstraintAxis)axis //待补充,ios6
- (void)setContentHuggingPriority:(UILayoutPriority)priorityforAxis:(UILayoutConstraintAxis)axis //待补充,ios6

AligningViews with Constraint-Based Layout //校准约束布局

- (CGRect)alignmentRectForFrame:(CGRect)frame //待补充,ios6
-(CGRect)frameForAlignmentRect:(CGRect)alignmentRect //待补充,ios6
-(UIEdgeInsets)alignmentRectInsets //待补充,ios6
- (UIView *)viewForBaselineLayout //待补充,ios6

TriggeringConstraint-Based Layout //触发约束布局

- (BOOL)needsUpdateConstraints //返回约束布局是否需要更新,YES为是,ios6
- (void)setNeedsUpdateConstraints //更新约束布局,ios6
- (void)updateConstraints //更新约束布局,ios6
-(void)updateConstraintsIfNeeded //更新约束布局及其子布局,ios6

DebuggingConstraint-Based Layout //调试约束布局

- (NSArray*)constraintsAffectingLayoutForAxis:(UILayoutConstraintAxis)axis //待补充,ios6
-(BOOL)hasAmbiguousLayout //待补充,ios6
-(void)exerciseAmbiguityInLayou//待补充,ios6

Drawingand Updating the View //绘制和更新视图

-(void)drawRect:(CGRect)rect //在view中绘制一个矩形
- (void)setNeedsDisplay//使view重绘
- (void)setNeedsDisplayInRect:(CGRect)invalidRect//指定矩形重绘
@property(nonatomic) CGFloat contentScaleFactor//待补充

Formatting PrintedView Content //格式化内容

- (UIViewPrintFormatter*)viewPrintFormatter //返回view的打印对象
- (void)drawRect:(CGRect)areaforViewPrintFormatter:(UIViewPrintFormatter *)formatter//使用某个区域来打印

Managing GestureRecognizers //管理手势

-(void)addGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer//添加手势识别器
- (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer //删除手势识别器
@property(nonatomic, copy) NSArray *gestureRecognizers//获取手势集合
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer //通过返回值决定是否识别此手势

Animating Views withBlocks //使多个view执行动画

+(void)animateWithDuration:(NSTimeInterval)durationdelay:(NSTimeInterval)delay options:(UIViewAnimationOptions)optionsanimations:(void (^)(void))animations completion:(void (^)(BOOLfinished))completion //使一个或多个view执行动画
+(void)animateWithDuration:(NSTimeInterval)duration animations:(void(^)(void))animations completion:(void (^)(BOOLfinished))completion //使一个或多个view执行动画
+ (void)animateWithDuration:(NSTimeInterval)durationanimations:(void(^)(void))animations //使一个或多个view执行动画
+ (void)transitionWithView:(UIView *)viewduration:(NSTimeInterval)durationoptions:(UIViewAnimationOptions)options animations:(void(^)(void))animations completion:(void (^)(BOOL finished))completion//在一个view上创建过渡动画
+ (void)transitionFromView:(UIView *)fromView toView:(UIView*)toView duration:(NSTimeInterval)durationoptions:(UIViewAnimationOptions)options completion:(void (^)(BOOLfinished))completion //

Animating Views //view动画 

+ (void)beginAnimations:(NSString *)animationID context:(void*)context //标志动画代码开始

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值