<分区>
<分区>
如何在使用 Storyboard时在窗口上添加按钮,我希望该按钮在所有屏幕上始终可见。
我尝试在窗口上添加图像,但它不可见。
UIWindow *window =[UIApplication sharedApplication].delegate.window;
UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
[img setBackgroundColor:[UIColor redColor]];
[window addSubview:img];
最佳答案
我没有添加 UIButton
,但在 appdelegate
中向 window
添加了 UIView
。
给你:
UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window)
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
svc = [[UIView alloc]initWithFrame(<some frame>)];
[[[window subviews] objectAtIndex:0] addSubview:svc];
希望对你有帮助
关于ios - Storyboard在窗口上添加一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23509534/