CATransform3D rotate causes half of image to disappear

后端 未结 3 1518
粉色の甜心
粉色の甜心 2021-02-07 04:05

I\'m using the following code to rotate an image, but half the image (down the y-axis) that has been rotated \"out of\" the page, disappears. How to fix? heading i

3条回答
  •  终归单人心
    2021-02-07 04:27

    Setting the anchorPoint to {0.0, 0.0} works as well (as Liam already pointed out).

    Here's the full code snippet for changing the anchorPoint without changing the layer's position on screen:

         layer.anchorPoint = CGPointMake( 0.0, 0.0 );
    
         CGPoint position = layer.position;
         CGSize size = layer.bounds.size;
    
         CGFloat posX = position.x - size.width / 2.0;
         CGFloat posY = position.y - size.height / 2.0;
    
         layer.position = CGPointMake( posX, posY );
    

提交回复
热议问题