0
我有一個uiimage,並使用CGAffineTransformMakeRotation將圖像旋轉到所需的角度。現在我想用imageview.center方法找出新圖像的新座標,即圖像的新x座標,y座標,寬度和高度如何在對象上使用CGAffineTransformMakeRotation後找到UIImage的座標
我有一個uiimage,並使用CGAffineTransformMakeRotation將圖像旋轉到所需的角度。現在我想用imageview.center方法找出新圖像的新座標,即圖像的新x座標,y座標,寬度和高度如何在對象上使用CGAffineTransformMakeRotation後找到UIImage的座標
由於您要求x,y,寬度,高度和不是我假設你想要旋轉圖像的邊界框的四個角落。你可以使用CGPath來計算。
// Your rotation transform
CGAffineTransform rotation = CGAffineTransformMakeRotation(angle);
// Create a path from the transformed frame
CGPathRef rotatedImageRectPath =
CGPathCreateWithRect(
imageView.frame, // rect to get the path from
&rotation // transform to apply to rect
);
// Get the bounding box from the path
CGRect boundingBox = CGPathGetBoundingBox(rotatedImageRectPath);