[英]How to Add a Semi Transparent UIView to a UIViewController
Upon a certain user action, I wish to add to my UIViewController another UIView that will be half transparent; 根据特定的用户操作,我希望将另一个半透明的UIView添加到我的UIViewController中。 ie when it loads, the UIViewController view in the back will still be visible in the background, and the new UIView will appear as a layer above it.
即,当它加载时,后面的UIViewController视图仍将在后台可见,并且新的UIView将在其上方显示为一层。
The "Half Transparent" UIView should have several images and buttons in it, so I prefer to create a separated h, m and xib files for it so I can control it. “半透明” UIView中应该包含多个图像和按钮,因此我更喜欢为其创建单独的h,m和xib文件,以便可以对其进行控制。
How should I do that? 我应该怎么做?
Try this: 尝试这个:
UIView *view = [[UIView alloc] init];
[view setAlpha:0.5];
[mainview addSubview:view]
[[NSBundle mainBundle] loadNibNamed:@"NibName" owner:self options:nil];
Once this is done, your custom will be loaded from the nib and assigned to the property you declared. 完成此操作后,将从笔尖加载您的自定义并将其分配给您声明的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.