1

I have an image as 30x30. I want to put this image into center of another 500x500 image and i want to define a background for 500x500 image like the following example. Is there any way to achieve this? Thank you.

İmages

rmaddy
  • 314,917
  • 42
  • 532
  • 579
ReadyFreddy
  • 898
  • 8
  • 20
  • Use AutoLayout and add the 500*500 image first and then add the 30*30 UIImage on top of it with a fixed height and width. – Jay Mayu Sep 21 '18 at 11:48
  • Btw if you could show what you have done so far, people here would be able to help you out. – Jay Mayu Sep 21 '18 at 11:57

3 Answers3

3

Set the image as following, just keep in mind that image's background color should be clear.

imageView.image = UIImage(named: "search_image")
imageView.contentMode = .center
Ankit Jayaswal
  • 5,549
  • 3
  • 16
  • 36
3

you can do this with the help of storyboard as shown in below picture.enter image description here

and output is :

enter image description here

Yash Bhikadiya
  • 188
  • 1
  • 9
0

Set width/height fix for the image. Insert into the background view with constraints centerX and centerY.

gmoraleda
  • 1,731
  • 1
  • 17
  • 44