2
遇到以下代码的问题。在iOS中设置全局背景图像或颜色
1.)我想要达到的目标; - 在iOS的AppDelegate中显示全局背景图像或颜色012) - 显示的图像或颜色表明代码正常工作,因为没有发生错误或警告。
3.)什么是问题; - 背景颜色或图像占据了整个屏幕,就像它是最顶层,因此我看不到任何元素,例如uitext,按钮等。只是背景图像...良好,因为它工作不好,因为,用户可以使用应用程序!
4.)我做了什么; - 下面是我一直在使用的appdelegate中的代码片段。我知道它在每个UIViewController中都有效,我试图重构它,所以我只在一个地方使用它。不是200!
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Set the background image
if (IDIOM == IPAD)
{
self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpg"]];
}
else
{
//Add gradient background
CAGradientLayer *bgLayer = [BackgroundLayer yellowGradient];
bgLayer.frame = self.window.bounds;
[self.window.layer insertSublayer:bgLayer atIndex:0];
}
//This is added so if in-app purchasing is used and the users connections fails in the middle of the transaction it will finalise the payment so it will download or give access to the purchase.
//[ReadingsIAPHelper sharedInstance];
return YES;
}
任何想法?
问候, 杰里米
您是否尝试过的子层发送到回来? – Wain
对不起...还在学习objC ....那会怎么做? – Jeremy
'[self.window.layer sendSublayerToBack:bgLayer];' – Wain