Ng Hsiao Qin
Ng Hsiao Qin

Reputation: 73

How to set position of UIImageView?

I am having an UIImageView as main view so when the main image tapped i add a subview which is another UIImageView and i would like to set the position of the ImageView of subview. Is there any suggestion?

Upvotes: 0

Views: 1945

Answers (1)

Mohamed.A.A
Mohamed.A.A

Reputation: 364

You have to place your image like this :

    let yourSecondImage = UIImageView(frame: CGRect(x: yourMainImage.frame.origin.x + xOffset, y: yourMainImage.frame.origin.y + yOffset, width: yourImageWidth, height: yourImageHeight))

Then use constraints to make your subview dynamically resized

yourMainImage.translatesAutoresizingMaskIntoConstraints = false

Upvotes: 1

Related Questions