user142019
user142019

Reputation:

Change UIView background color programmatically

I've just created a new view based application, and now I want to set the background color at the application startup rather then in IB. I have found this code in a tutorial:

UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
[view setBackgroundColor:[UIColor greenColor]];

But my view is still white.

How do I make it work?

Thanks in advance.

Upvotes: 13

Views: 29824

Answers (1)

Philippe Leybaert
Philippe Leybaert

Reputation: 171774

This should work. Are you adding the view to the window using addSubView ?

Upvotes: 6

Related Questions