LoginSignup
0
0

More than 1 year has passed since last update.

UIImageViewでAspectFitを指定した時の画像サイズを取得する

Last updated at Posted at 2022-12-10

imageView.frame.sizeでUIImageViewのサイズを取得するみたいに、imageView.image.frame.sizeのように取得したいができない、、、

方法

import AVFoundation

guard let image = imageView.image else { return }
let frame = AVMakeRect(aspectRatio: image.size, insideRect: imageView.bounds)

print("x = \(frame.origin.x)")
print("y = \(frame.origin.y)")
print("height = \(frame.size.height)")
print("width = \(frame.size.width)")

参考記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0