About anchorPoint and anchorpoint

Source: Internet
Author: User

About anchorPoint and anchorpoint

The anchorPoint attribute is CGPoint (x, y), and the value of x and y is proportional. Generally, the value ranges from 0 ~ 1. The default value is (0.5, 0.5), indicating the position of the layer in its own position. For example,

After the size and position of the red view are determined, if you modify the anchorPoint of the layer, the center position of the red view is offset. At this time, the positioning point is at the place pointed by the arrow, the value of anchorPoint is () in the upper left corner of the layer, and () in the lower right corner. The center of the layer is changed because of the change of anchorPoint. For details about anchorPoint, refer to the upper left corner () and lower right corner) in this example, anchorPoint = (0.5, 1), the view will move up the height of the 0.5 layers. At this time, anchorPoint is in the position of the arrow,

 

AnchorPoint is essentially a point, but when the View frame is determined first, it changes the center point of the layer. The anchorPoint value depends on the layer,

In this question, if you write v first. layer. anchorPoint, and then write v. frame, the center of the view remains unchanged, but the coordinates of the positioning point have changed, because the positioning point cannot change the center point of the layer when the layer position does not exist.

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.