3

I have an UIimageview but when the picture is taken, the image does not follow the size of UIimageview like this enter image description here

I want it like this enter image description here

Firuma
  • 105
  • 12
  • Have you tried changing the [`UIImageView`'s `contentMode`](https://stackoverflow.com/questions/14134035/how-to-manage-uiimageview-content-mode)? – MadProgrammer Nov 12 '18 at 02:20
  • I tried it, but the picture became irregular, I want the image to be cut according to the uiimageview, so that it looks good – Firuma Nov 12 '18 at 02:31
  • 1
    Set `clipToBounds` to true. You could also use `aspectToFit` or `aspectToFill` depending on your needs – MadProgrammer Nov 12 '18 at 02:32
  • right, I tried and succeeded, thanks @MadProgrammer – Firuma Nov 12 '18 at 02:36

2 Answers2

1

You should set the clipToBounds property of the UIImageView to true. This will solve your problem. Learn more at https://developer.apple.com/documentation/uikit/uiview/1622415-clipstobounds

sanjaykmwt
  • 586
  • 3
  • 19
0

Try :

UIImageView.clipsToBounds = true
Mahgolsadat Fathi
  • 3,107
  • 4
  • 16
  • 34