stitch picture in iphone

后端 未结 3 1277
孤城傲影
孤城傲影 2021-01-03 13:27

I want to stitch 2 pieces of png side by side. In Cocoa, I would use [NSImage initWithSize], and then just drawInRect.

But UIImage don\'t have initWithSize class, h

3条回答
  •  太阳男子
    2021-01-03 14:31

    Use UIGraphicsBeginImageContext(), draw in it, then use UIGraphicsGetImageFromCurrentImageContext(). Remember to pop the context with UIGraphicsEndImageContext() afterwards.

    You should avoid creating an extra image if you simply want to display the two images onscreen, due to the limited memory available on the device. Instead, display them using appropriate drawInRect: calls to avoid copying.

提交回复
热议问题