方法1:
UIImage *backgroundImg=[UIImage imageNamed:@"5.jpg"];
UIImageView *backgrounImgView=[[UIImageView alloc]initWithImage:backgroundImg];
[self.view addSubview:backgrounImgView];
[self.view sendSubviewToBack:backgrounImgView];
这种方法如果图片的大小超过屏幕的实际尺寸( 未定义实际大小的情况下),则在做navigation导航back的时候,会发现图片延伸到detailview去了
方法2:
self.view.backgroundColor=[UIColorcolorWithPatternImage:[UIImageimageNamed:@"5.jpg"]];
这种方法能够正好填充 至整个屏幕,无需对背景图片做任何调整。
本文详细介绍了在iOS应用中如何设置全屏背景图片,并提供了两种方法:一种是使用UIImageView添加背景图片,另一种是通过view.backgroundColor填充整个屏幕。文章强调了选择合适的方法以避免在导航操作时出现背景图片延伸到detailview的问题。
600

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



