开发者

Layers of Images using UIImageView

I just wanted to confirm, is it possible that we add layers of images using UImageView, one as background and other on top of it. I mean i want to use 2 images one has to be in the background and the other on top of it. ( the size of both these images is 320 x 480 ).

Through the attributes i开发者_StackOverflow社区nspector we cant do it. Is there any we can do it through code. Maybe using subview or something.


You need one UIImageView for each image, but they will appear layered as long as the top view is not opaque. You could put both image views into a third UIView if you want to treat them as a single entity.

Edit:

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 is now a UIView with a background and foreground image.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜