i am displaying thumbnail images from youtube in my iOS app. which upon click, will go to youtube.
I need a way of overlaying a play button onto those images. What might be the most straightforward way of doing so?
Also, the images are remotely loaded onto a table, so performance is a big consideration
You can easily put a photo on top of another photo using Fotor, a free online photo editor. Simply drag and drop the image you want to overlay into Fotor- this will become your background picture. Then add a new image over it. You can adjust the transparency levels to blend two images together perfectly.
The iPhone doesn't come pre-installed with any features that allow you to merge pictures together. But you can do what you want with the Shortcuts app. Shortcuts are built-in automation tools on the iPhone. It can merge pictures together.
If you are concerned with table scrolling performance, retrieve the thumbnail and paint the play button over it.
+(UIImage*) drawImage:(UIImage*) fgImage inImage:(UIImage*) bgImage atPoint:(CGPoint) point { UIGraphicsBeginImageContextWithOptions(bgImage.size, FALSE, 0.0); [bgImage drawInRect:CGRectMake( 0, 0, bgImage.size.width, bgImage.size.height)]; [fgImage drawInRect:CGRectMake( point.x, point.y, fgImage.size.width, fgImage.size.height)]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; }
Swift 2.2 Version
static func drawImage(image foreGroundImage:UIImage, inImage backgroundImage:UIImage, atPoint point:CGPoint) -> UIImage{ UIGraphicsBeginImageContextWithOptions(backgroundImage.size, false, 0.0) backgroundImage.drawInRect(CGRectMake(0, 0, backgroundImage.size.width, backgroundImage.size.height)) foreGroundImage .drawInRect(CGRectMake(point.x, point.y, foreGroundImage.size.width, foreGroundImage.size.height)) let newImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return newImage }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With