我怎么能改变iPhone的视图背景?

时间:2013-03-21 10:02:13

标签: iphone ios5

我使用过此代码。但是,视图背景没有改变。

UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background.png"]];
[[self view] setBackgroundColor:background];
[background release];

2 个答案:

答案 0 :(得分:3)

尝试:

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];

它会节省您的记忆以创建背景变量。

答案 1 :(得分:0)

我想你没有这个形象。

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"settings_Icon_1X.png"]];
    [[self view] setBackgroundColor:background];
    [background release];
}

请将图像添加到项目文件夹

相关问题