How to combine two UIImages of difference size without altering their original aspect ratios?

后端 未结 4 1222
说谎
说谎 2021-01-26 10:29

My current method of combining UIImages come from this answer on SO, as well as this popular question on resizing UIImage with aspect ratio. My current issue is the following:<

4条回答
  •  闹比i
    闹比i (楼主)
    2021-01-26 10:57

    When you call [self.drawView.image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; you need to modify the frame to account for the difference in aspect ratio that you described (because you are chopping some of the image off on both sides).

    That means modifying the x position and the width that you are drawing the annotation image.

    The modification is based on the difference between the 2 rects when scaled to the same height. You say this is 304, so you can initially set x to 304 and the width to newSize.width - 608 to test. But really the difference should be calculated...

提交回复
热议问题