iOS development--using OC Chapter &frame,bounds,center,position,anchorpoint Summary

Source: Internet
Author: User

Frame,bounds,center,position,anchorpoint Summary

The position property of a layer is a Cgpoint value that specifies the position of the layer as its parent layer, based on the parent layer's coordinate system.

The bounds property of a layer is a CGRect value that specifies the layer's size (bounds.size) and the layer's origin (bounds.origin). When you rewrite a layer's redraw method, the origin of the bounds can be used as the origin of the graphics context.

The layer has an implicit frame, which is part of the Position,bounds,anchorpoint and transform properties. Setting a new frame will change the layer's position and bounds properties accordingly, but the frame itself is not saved. But when the new frame is set, the origin of the bounds is undisturbed, and the size of the bounds becomes the size of the frame, which is bounds.size=frame.size.

The position of the layer is set to the appropriate position relative to the anchor Point (anchor points) . When you set the value of a frame, it is calculated in relation to the properties of position, bounds, and Anchorpoint.

When you set the frame property of a layer, the position will change according to the anchor (Anchorpoint), and when you set the Position property of the layer, bounds will change according to the anchor Point (anchorpoint) accordingly.

Frame,center and Bounds Properties

1.frame, center, and bounds properties
    • Frame: Controlling Position and size
    • Center: Control Position (center point)
    • Bounds: Control size (in its own upper left corner as the origin)
2. Attention points

(1) The position of the control can be modified by the following properties

    • Frame.origin
    • Center

(2) The size of the control can be modified by the following properties

    • Frame.size
    • Bounds.size

Position,anchorpoint

    • Position: is a place where we need to set the control to use

For example: btn.position = cgpointmake (0, 0); the position of our corresponding control is (0,0)

But you think there are countless points in the control, how do you know that point as the point we're going to set, of course, we're all the center of the norm, but it's not the only one, so there's anchorpoint.

    • Anchorpoint: Think that the point above the control is the corresponding point I want to set

Sometimes we will combine the above several properties to use, but according to the requirements of anchorpoint is generally used to implement not around the center point rotation function, two if we do not modify Anchorpoint, position default is the midpoint (parent control)

iOS development--using OC Chapter &frame,bounds,center,position,anchorpoint Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.