Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Position and anchorPoint properties of CALayer

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

In iOS, UIView such as UIButton and UIImage can be displayed on the screen because there is a layer (CALayer) inside it. You can access this layer through the layer property of UIView:

@ property (nonatomic,readonly,retain) CALayer * layer

When the UIView needs to be displayed on the screen, the drawRect: method will be called to draw, and all the content will be drawn on its own layer. After the drawing is finished, the system will copy the layer on the screen, so the display of the UIView will be completed.

There are two confusing attributes in UIView, postion and anchorPoint (anchor point). Postion is used to set the position of CALayer in the parent layer, and anchorPoint determines which point on CALayer will be on the postion point. For example, the red × × layer should be added to the green × × layer.

(1) positon is (100100), anchorPoint is (0J0), and the effect is as follows

(2) positon is (100100), anchorPoint is (0.5), and the effect is as follows.

(3) positon is (100100), anchorPoint is (1). The effect is as follows.

(4) positon is (100100), anchorPoint is (1c0.5). The effect is as follows.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report