UIView *v = [[UIView alloc]initWithFrame:CGRectMake(200, 200, 200, 200)];
v.backgroundColor = [UIColor redColor];
[self.view addSubview:v];
backgroundColor
The view’s background color.
背景颜色
hidden
A Boolean value that determines whether the view is hidden.
是否隐藏
alpha
The view’s alpha value.
透明度 0.0-1.0
opaque
A Boolean value that determines whether the view is opaque.
不透明的 YES or NO
tintColor
The first nondefault tint color value in the view’s hierarchy, ascending from and starting with the view itself.
tintAdjustmentMode
The first non-default tint adjustment mode value in the view’s hierarchy, ascending from and starting with the view itself.
clipsToBounds
A Boolean value that determines whether subviews are confined to the bounds of the view.
clearsContextBeforeDrawing
A Boolean value that determines whether the view’s bounds should be automatically cleared before drawing.
maskView
An optional view whose alpha channel is used to mask a view’s content.
layerClass
Returns the class used to create the layer for instances of this class.
layer
The view’s Core Animation layer used for rendering.
userInteractionEnabled
A Boolean value that determines whether user events are ignored and removed from the event queue.
点击是否有效
multipleTouchEnabled
A Boolean value that indicates whether the view receives more than one touch at a time.
多点触屏
exclusiveTouch
A Boolean value that indicates whether the receiver handles touch events exclusively.
接受管理是否唯一
frame
The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.
bounds
The bounds rectangle, which describes the view’s location and size in its own coordinate system.
描述在自己的坐标系统中的位置和大小
center
The center point of the view’s frame rectangle.
frame的中心坐标,用来移动视图
transform
Specifies the transform applied to the view, relative to the center of its bounds.
转换,例如:移动、缩放、旋转等
superview
The receiver’s superview, or nil if it has none.
父视图,只有一个
subviews
The receiver’s immediate subviews.、
子视图,可以有多个
- addSubview:
Adds a view to the end of the receiver’s list of subviews.
添加
- removeFromSuperview
Unlinks the view from its superview and its window, and removes it from the responder chain.
删除
Define how a view adjusts its content when its bounds change.
contentMode
A flag used to determine how a view lays out its content when its bounds change.
当 bounds 改变时如何布局
autoresizingMask
An integer bit mask that determines how the receiver resizes itself when its superview’s bounds change.
父视图 bounds 改变时自身大小如何调整
autoresizesSubviews
A Boolean value that determines whether the receiver automatically resizes its subviews when its bounds change.
bounds 改变时其子视图是否跟着自动调整 YES or NO
Lay out views manually if your app does not use Auto Layout.
- layoutSubviews
Lays out subviews.
布局子视图
- setNeedsLayout
Invalidates the current layout of the receiver and triggers a layout update during the next update cycle.
- layoutIfNeeded
Lays out the subviews immediately, if layout updates are pending.