UIView Class Reference

转载自 http://www.cnblogs.com/cat3/archive/2013/04/07/3006125.html

Initializing a View Object //初始化view

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

Configuring a View’s Visual 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 //返回Core Animation层所使用的渲染方式

Configuring the Event-Related Behavior //配置事件关系

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

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

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

Managing the 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)index1 withSubviewAtIndex:(NSInteger)index2 //交换两个view的索引
- (BOOL)isDescendantOfView:(UIView *)view //判断是不是指定元素的子节点或是其本身

Configuring the Resizing 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的尺寸去适应其内容

Laying out Subviews //布局子节点

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

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

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

Managing Constraints //约束管理

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

Measuring in Constraint-Based Layout //测量约束布局

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

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

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

Triggering Constraint-Based Layout //触发约束布局

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

Debugging Constraint-Based Layout //调试约束布局

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

Drawing and Updating the View //绘制和更新视图

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

Formatting Printed View Content //格式化内容

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

Managing Gesture Recognizers //管理手势

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

Animating Views with Blocks //使多个view执行动画

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

Animating Views //view动画

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

时间: 2024-08-07 12:52:30

UIView Class Reference的相关文章

UIView你知道多少

转载自:http://www.cnblogs.com/likwo/archive/2011/06/18/2084192.html 曾经有人这么说过,在iphone里你看到的,摸到的,都是UIView,所以UIView在iphone开发里具有非常重要的作用.那么UIView我们到底知道多少呢.请看看下面的问题, 如果这些你都知道,那么本文章的内容就请绕道,如果你还不太清楚,我想看了下面的内容,你就明白了. 1.bounds和frame分别表示什么? 2.ContentMode里UIViewCont

关于UIView(转)

曾经有人这么说过,在iphone里你看到的,摸到的,都是UIView,所以UIView在iphone开发里具有非常重要的作用.那么UIView我们到底知道多少呢.请看看下面的问题, 如果这些你都知道,那么本文章的内容就请绕道,如果你还不太清楚,我想看了下面的内容,你就明白了. 1.bounds和frame分别表示什么? 2.ContentMode里UIViewContentModeScaleToFill代表什么? 3.contentStretch 里的指定UIView里缩放区域是如何计算的? 4

详解 UIView 的 Tint Color 属性

在iOS 7后,UIView新增加了一个tintColor属性,这个属性定义了一个非默认的着色颜色值,其值的设置会影响到以视图为根视图的整个视图层次结构.它主要是应用到诸如app图标.导航栏.按钮等一些控件上,以获取一些有意思的视觉效果. tintColor属性的声明如下: var tintColor: UIColor! 默认情况下,一个视图的tintColor是为nil的,这意味着视图将使用父视图的tint color值.当我们指定了一个视图的tintColor后,这个色值会自动传播到视图层次

UIView的理解 [转]

[转载] 原文地址 :http://blog.csdn.net/itianyi/article/details/8982518 UIView是开发中使用得最多的控件了,深入的理解很有必要. UIView是组成画面的基本元素, NS_CLASS_AVAILABLE_IOS(2_0)@interface UIView :UIResponder<NSCoding,UIAppearance, UIAppearanceContainer> { @package CALayer        *_laye

iOS 8 UITableViewCell 分割线 左对齐

//加入如下代码 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{          if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {         [tableView setSeparatorInset:U

iOS Drawing Concepts[iOS 绘画概念]

iOS Drawing Concepts https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html High-quality graphics are an important part of your app’s user interface. Providin

【IOS笔记】Views

Views Because view objects are the main way your application interacts with the user, they have many responsibilities. Here are just a few: 通过view对象是与用户交互的主要方式,它们有很多责任,下面是其中一些: Layout and subview management   布局 A view defines its own default resizin

iOS UIKit 框架 346 篇文档分类整理 - 预告

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 当前正在进行的是 "iOS Foundation 框架 224 篇相关文档分类整理",量很大,但会根据实际开发中的使用频繁程序

debugging Auto Layout:Debugging Tricks and Tips

Debugging Tricks and Tips调试技巧和技巧 The following topics describe techniques for gathering and organizing information about your layout, as well as descriptions of some surprising behaviors you may encounter. You may not need to use these techniques on