frame&bounds¢er--when to use them

answer from stack overflow
http://stackoverflow.com/questions/1071112/uiviews-frame-bounds-center-origin-when-to-use-what

frame - this is the property you most often use for normal iPhone applications. most controls will be laid out relative to the "containing" control so the frame.origin will directly correspond to where the control needs to display, and frame.size will determine how big to make the control.
frame:是一个常规ios应用中最常用到的property,大多数controls的布局是和contain这个control的control相关的,所以frame.origin就是直接对应的control应该显示的地方,而frame.size决定了这个control的大小。

center - this is the property you will likely focus on for sprite based games and animations where movement or scaling may occur. By default animation and rotation will be based on the center of the UIView. It rarely makes sense to try and manage such objects by the frame property.
center:这是在使用spritekit做的游戏或者动画效果中移动/改变大小的时候常常用到的property,默认来讲,动画和转动是在UIView的center的基础上进行的。所以若是使用frame property来操作这些动作也就有些不合理了。

bounds - this property is not a positioning property, but defines the drawable area of the UIView "relative" to the frame. By default this property is usually (0, 0, width, height). Changing this property will allow you to draw outside of the frame or restrict drawing to a smaller area within the frame. It is uncommon for this property to be manipulated unless there is specific need to adjust the drawing region. The only exception is that most programs will use the [[UIScreen mainScreen] bounds] on startup to determine the visible area for the application and setup their initial UIView's frame accordingly.
bounds:这个property不是一个位置property,但是它定义了对于frame来讲UIView的可使用范围。默认来说,这个property通常是(0,0,width,height).通过改变这个property的值,你可以在frame之外绘制,或者在比frame还要小的范围里绘制。除非是要控制绘制的区间,否则我们一般是不使用这个property的。一个例外:大部分程序会在启动时使用[[UIScreen mainScreen] bounds]来确定应用的可视范围,并相应的设置初始UIView的frame。

你可能感兴趣的:(frame&bounds¢er--when to use them)