view 的Frame和bound

frame:指的是視圖在父視圖的座標系統中的大小和位置。html

bound:指的是視圖在試圖自己的座標系統中的大小(位置起點是原點)。ios

center:指的是視圖在父視圖座標系統中的中心點。app

貼張蘋果官網的圖:less

frame和bound的關係ide

Relationship between a view's frame and bounds


下面這是其中一個發生變化,其他兩個的變化,直接看吧,很淺顯。this


Although you can change the framebounds, and center properties independent of the others, changes to one property affect the others in the following ways:spa

  • When you set the frame property, the size value in the bounds property changes to match the new size of the frame rectangle. The value in the center property similarly changes to match the new center point of the frame rectangle.code

  • When you set the center property, the origin value in the frame changes accordingly.orm

  • When you set the size of the bounds property, the size value in the frame property changes to match the new size of the bounds rectangle.htm

By default, a view’s frame is not clipped to its superview’s frame. Thus, any subviews that lie outside of their superview’s frame are rendered in their entirety. You can change this behavior, though, by setting the superview’s clipsToBounds property to YES. Regardless of whether or not subviews are clipped visually, touch events always respect the bounds rectangle of the target view’s superview. In other words, touch events occurring in a part of a view that lies outside of its superview’s bounds rectangle are not delivered to that view.

相關文章
相關標籤/搜索