[英]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.