Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ビューのスケールモードがに設定されているときににUIImage表示されるのX座標を取得することは可能ですか?UIImageViewCenter
UIImage
UIImageView
Center
私が欲しいものをよりよく説明するための画像:
それはかなり基本的な数学です:
CGFloat x = (imageView.frame.size.width - imageView.image.size.width) / 2;
違うと思う。
しかし、回避策があります。画像の高さと幅を計算でき、それに応じて、(imageView.frame.size.width-image.size.width)/2高さについても同じことで中心位置を計算できます。
(imageView.frame.size.width-image.size.width)/2
これで問題が解決することを願っています。