Search code examples
iosobjective-cuiviewbackground-coloruicolor

Change the Background Color of a UIView


I have a problem setting the background color of an UIView. I'm using the following code:

self.view.backgroundColor = [UIColor colorWithRed:0 
                                            green:0.675 
                                             blue:0.929 
                                            alpha:1];

This is working fine when I'm setting the background color right at the start of the app, but when I want to update my background color after I launched my app from a notification center widget, it doesn't change the color.


EDIT – Some more details:

When the app is launched from the notification center, an AppDelegate method is called, which saves the called URL Scheme as a `NSString and calls another method in which the background color should be updated.

I've verified the method call works fine.

My problem is that the color isn't updated although the method is called.


Solution

  • I have fixed my problem. In AppDelegate.m, in the method where I got the URL with which the App was launched, I initialized a new ViewController instead of using the old one, which caused all my errors. Thank you for you help!