How can I change the color of a UIWindow from a separate class?

How can I change the color of a UIWindow from a separate class?

I am trying to change the background color of a UIWindow when an action is sent to the class MyController. However the UIWindow resides in the AppDelegate class so I don't have access to the variable to modify it using

window.backgroundColor = [UIColor theColor]; 

in MyController. Here is the code for MyController.m:

@implementation MyController - (IBAction)sliderChanged:(id)sender {  //want to call some method to change the UIWindow background color } @end

And here is the code for AppDelegate.h:

 @interface AppDelegate : NSObject  {     UIWindow *window; }  - (void)changeColorToRed:(int)r Green:(int)g Blue:(int)b;  @property (nonatomic, retain) IBOutlet UIWindow *window;  @end 

I tried to implement a method changeColorToRed... in the AppDelegate class because that method has access to the variable window, but I had no way to call that from the sliderChanged method in MyController.

How can I modify the UIWindow * window from another class?

Find tags with no classes and add a class


Utilizing objects in another class in Python
[UIApplication sharedApplication].delegate.window.backgroundColor = [UIColor myColor]; 
If there's only 1 window,.
In C#, can a class inherit from another class and an interface?
[UIApplication sharedApplication].keyWindow.backgroundColor = [UIColor myColor]; 

C++ object class problems when used in another class

How to run database class methods inside other classes?


How to define a common variable in javascript Class that can be used across instances?
I think you could either:.
Easiest way to make C# not instantiate a class unless inherit?
Make some static method in the class containing the window variable.
What is the best way to pass or access other objects in other classes in PHP?
or. Pass the window variable to the new class.


76 out of 100 based on 86 user ratings 886 reviews