开发者

problems an opaque on the interface builder

i'm studying iOS programming. but i have a problem, which is opaque.

now assume. i have two image views.

when i write code, it works. code is here.

UIImageView *imageView1 = [[UIImageView alloc] initWithImage:@"something1"];
UIImageView *imageView2 = [[UIImageView alloc] initWithImage开发者_如何学Python:@"something2"];
imageView2.opaque = NO;
[controller addSubView:imageView1];
[controller addSubView:imageView2];

now, imageView2 is on the imageView1. but imageView2's property opaque set to NO.

so i can see imageView1 only. ok. that's what i want.

but i want to do more easily. so i use interface builder.

i have two image views. one is wire up IBOutlet ImageView *imageView1

and another one is IBOutlet ImageView *imageView2.

and i set the imageView2's inspector. and uncheck opaque.

and i build it. so i think it's same effect as code above.

but imageView2 is on the imageView1.

it's not disappear.

why is that?

why code can work but interface builder not?


UIView's opaque property is used for determining whether the view can optimize compositing operations. You should be setting the alpha property.


Subviews added in code will be placed on top of each other in the order you call addSubview. To add a subview in a specific Z-position use insertSubview: atIndex:.

In interface builder you have to manually control the layering using the menus (send to back, etc), otherwise the last added view will be on top.

The opaque setting should be set to YES if you want a view to completely obscure the view underneath. If you want the views underneath to show through, set opaque to NO and set the alpha (transparency) as you wish.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜