iOS设置背景图片

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"]];

猜你喜欢

转载自duchengjiu.iteye.com/blog/1897618
今日推荐