1. 使用一个UIImageView实例做子视图,并且放最后面
UIImageView *customBackgournd = [UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.jpg"]];
self.background = customBackground;
[customBackground release];
[self addSubview:background];
[self sendSubViewToBack:background];
2.
UIImageView *contentView = [UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
[contentView setImage:[UIImage imageNamed:@"background.jpg"]];
[contentView setUserInteractionEnabled:YES];
self.view = contentView;
[contentView release];
3.
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpg"]];
http://laiguowei2004.blog.163.com/blog/static/36829000201262710191770/
UIImageView *customBackgournd = [UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.jpg"]];
self.background = customBackground;
[customBackground release];
[self addSubview:background];
[self sendSubViewToBack:background];
2.
UIImageView *contentView = [UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
[contentView setImage:[UIImage imageNamed:@"background.jpg"]];
[contentView setUserInteractionEnabled:YES];
self.view = contentView;
[contentView release];
3.
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpg"]];
http://laiguowei2004.blog.163.com/blog/static/36829000201262710191770/
本文介绍了三种在iOS应用中设置背景图的方法:使用UIImageView实例并置于底层;将背景图设置为视图的内容;通过UIColor的patternImage方法设置背景。这些方法适用于不同的应用场景。
1837

被折叠的 条评论
为什么被折叠?



