繁体   English   中英

使用UIImageView的图像层

[英]Layers of Images using UIImageView

我只是想确认一下,我们是否有可能使用UImageView添加图像层,一个作为背景,另一个作为背景。 我的意思是我想要使用2个图像,一个必须在背景中,另一个在它上面。 (这两幅图像的尺寸均为320 x 480)。

通过属性检查器,我们无法做到。 有没有我们可以通过代码来做到这一点。 也许使用子视图或其他东西。

每个图像需要一个UIImageView,但只要顶视图不是不透明的,它们就会显示为分层。 如果要将它们视为单个实体,可以将两个图像视图放入第三个UIView中。

编辑:

imageBackground = [[UIImageView alloc] initWithImage:[UIImageNamed:@"background.png"]];
imageForeground = [[UIImageView alloc] initWithImage:[UIImageNamed:@"foreground.png"]];
imageLayered = [[UIView alloc] initWithFrame:[imageBackground frame];

[imageLayered addSubview:imageBackground];
[imageLayered addSubview:imageForeground];

// release all views at some point.

imageLayered现在是一个带有背景和前景图像的UIView。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM