如何更改iphone视图背景?
我用过这个代码。但是,视图背景没有改变如何更改iphone视图背景?,iphone,ios5,Iphone,Ios5,我用过这个代码。但是,视图背景没有改变 UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background.png"]]; [[self view] setBackgroundColor:background]; [background release]; 尝试: 创建背景变量将节省您的内存。我想您没有图像 - (void)viewDidLoad { [super vi
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background.png"]];
[[self view] setBackgroundColor:background];
[background release];
尝试:
创建背景变量将节省您的内存。我想您没有图像
- (void)viewDidLoad
{
[super viewDidLoad];
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"settings_Icon_1X.png"]];
[[self view] setBackgroundColor:background];
[background release];
}
请将图像添加到项目文件夹这应该可以。另外,请确保background.png存在。@ArtemKalachev好的观点:)非常感谢,它现在可以工作了。我的问题是1-图像名称2-视图图形不透明被选中上述代码适用于我怀疑你有一个零的地方,可能是UIImage,或视图本身。尝试使用[UIColor REDCLOR]作为缩小范围的颜色。您是否检查了图像是否更清晰谢谢,它现在可以工作了。我的问题是1-图像名称2-已选择视图图形不透明(是)不应选择这两个选项都正确,但第一个答案节省内存
- (void)viewDidLoad
{
[super viewDidLoad];
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"settings_Icon_1X.png"]];
[[self view] setBackgroundColor:background];
[background release];
}