Configuring the Bounds and Frame Rectangles
frame
Property
The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.
框架矩形描述了所属视图的在上一级视图中的坐标和大小
Declaration
SWIFT
var frame: CGRect
OBJECTIVE-C
@property(nonatomic) CGRectframe
Discussion
This rectangle defines the size and position of the view in its superview’s coordinate system. You use this rectangle during layout operations to size and position the view. Setting this property changes the point specified by the center
property and the size in the bounds
rectangle accordingly. The coordinates of the frame rectangle are always specified in points.
这个矩形定义了所属视图在上一级视图坐标系中的大小和位置。在布局操作的时候使用这个矩形来定位视图和设置视图的大小。设置这个属性会相应地改变 center 属性设置的点和 bounds 矩形设置的大小
WARNING
If the transform
property is not the identity transform, the value of this property is undefined and therefore should be ignored.
如果 transform 属性 不是恒等变换(?),frame属性的值是未定义的,那么frame属性的值应该被忽略。
Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect:
method. If you want the drawRect:
method invoked when the frame rectangle changes, set the contentMode
property to UIViewContentModeRedraw
.
改变框架矩形自动地在没有调用 drawRect: 方法重新显示接收器。如果你想在frame改变的时候调用drawRect:方法,查看 UIViewContentModeRedraw 的contentMode 属性。
Changes to this property can be animated. However, if the transform
property contains a non-identity transform, the value of the frame
property is undefined and should not be modified. In that case, you can reposition the view using the center
property and adjust the size using the bounds
property instead.
该值的改变可以是有动画的。然而,如果transform 属性包含了 非恒等 改变,frame属性的值是未定的也不应该被修改。在这种情况,你可以取而代之使用 center属性重新定位视图,使用 bounds 属性来调整它的大小。
Import Statement
import UIKit
Availability
Available in iOS 2.0 and later.
纯属原创,转载请注明!