self.view.backgroundColor = [UIColor greenColor];在推送视图中不起作用
我想在推送视图的 drawRect
中绘制一些东西。 另外,我想改变视图的背景颜色。
如果视图是主视图,我可以通过 viewDidLoad
中的 self.view.backgroundColor = [UIColor greenColor];
更改背景颜色。
我在推送的视图控制器
的viewDidLoad
中使用了它,但它仍然是黑色的。
MyViewController *myViewController = [MyViewController alloc]init];
[self.navigationContoller pushViewController:myViewContoller animated:YES]; // I want to change background color of this view.
[myViewController release];
I want to draw something in drawRect
of pushed view.
Also, I want to change back ground color of view.
I can change background color by self.view.backgroundColor = [UIColor greenColor];
in viewDidLoad
, if view is main view.
I used that in viewDidLoad
of pushed view controller
, but it is still black.
MyViewController *myViewController = [MyViewController alloc]init];
[self.navigationContoller pushViewController:myViewContoller animated:YES]; // I want to change background color of this view.
[myViewController release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在推送之前设置 myViewController 的背景颜色应该可以。
或者您可以转到该视图的 viewWillAppear 并在那里设置背景颜色。
Setting the
myViewController
's background color before pushing it should work.Or you can go to the
viewWillAppear
of that view and set the backgroundColor there.在 Apple Swift 中,我们可以使用:
背景将变为绿色
In Apple Swift, We can use:
Background will change to Green
实际上,您应该在推送视图的
viewDidLoad
中自定义您的视图。这就是它的用途。You actually should customize your view in
viewDidLoad
of your pushed view. Thats what it is made for.