我需要将viewcontroller的背景设置为图像。在阅读其他SO答案之后,我发现我们应该放置代码:
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"login_page_bg.png"]]]
进入viewDidLoad
我这样做了但仍然是白色背景。我的login_page_bg.png位于我的XYZLoginPageViewController.m所在的文件夹中。我做错了什么?
答案 0 :(得分:2)
在视图上拍摄imageview。
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background-image"]];
bgImageView.frame = self.view.bounds;
[self.view addSubview:bgImageView];
[self.view sendSubviewToBack:bgImageView];