ios - How to calculate relative tap location in UIImageView -
I have a UIImageView that loads images with different aspect ratios to display the whole image properly Using UIViewContentModeScaleAspectFit.
I need to allow users to tap the image and tag friends. How to calculate the X and Y percent of the tap space relative to the actual image content - Since the UIImageView contains the top-bottom or side padding to satisfy the UIViewContentModeScaleAspectFit barrier I need to be able to separate from the percentage calculation is.
In addition, inversion is needed when UIImageView should be provided with the image and tag.
There is an easy way with built-in function.
[imageViewSet Frame: AVMakeRectWithAspectRatioInsideRect (image.size, ImageView.frame)]
You can, of course, underscore the wheel again and Do a bunch of hand calculations.
Comments
Post a Comment