通过导入图像更改UIWindow的背景?

时间:2013-01-27 18:50:37

标签: ios uiview

我正在使用这个可用的示例代码来创建一个简单的应用程序......我唯一需要做的就是将背景更改为计算机上的图像。我正在使用的示例代码可用here。我不知道在哪里以及如何实现我可以用来设置背景图像的代码(如下所示)。如果有人可以提供一些关于如何将下面的代码合并到我正在使用的示例代码中的建议,我将非常感激。

我正在尝试将此代码实现到上面提供的应用代码中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"BrainBrain.png"]];
    self.window.backgroundColor = background;
    [self.window makeKeyAndVisible];
    return YES;
}

1 个答案:

答案 0 :(得分:5)

只需放置这两行

即可
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"BrainBrain.png"]];
self.window.backgroundColor = background;

进入application:didFinishLaunchingWithOptions:launchOptions:

AppDelegate方法
相关问题