在iOS中将图像叠加在另一个图像上 [英] Overlay an image over another image in iOS

查看:451
本文介绍了在iOS中将图像叠加在另一个图像上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS应用中显示来自youtube的缩略图。单击后,将转到youtube。

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

推荐答案

如果您关心表滚动性能,请检索缩略图并在其上绘制播放按钮。

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;
}

这篇关于在iOS中将图像叠加在另一个图像上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆