Iphone stitch photo

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

But UIImage does not have an initWithSize class, how would I do it now?

+2
source share
3 answers

Use UIGraphicsBeginImageContext() , draw it, then use UIGraphicsGetImageFromCurrentImageContext() . Remember to then add the UIGraphicsEndImageContext() context.

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

+8
source

if you are trying to create a new image with two-component images in it, try using UIGraphicsBeginImageContext (size) and UIGraphicsGetImageFromCurrentImageContext (). Together they should allow you to create a new size image that you would like to work with, draw it in and pull out a new UIImage object.

+1
source

The Apple TheElements demo (AtomicElementViewController) has a great example of how to do this. As well as how to create a reflection and a beveled look.

0
source

Source: https://habr.com/ru/post/1391215/


All Articles