Introduction
In this article we change the background color of a UI Window of iPhone via coding in the appdelegate.m class. To better understand use the following procedure.
Step 1
Open XCode by double-clicking on it.
Step 2
Create a New XCode Project by clicking on it.
Step 3
Now select Empty Application and click on Next.
Step 4
Now give your Product Name. Here I give Background and Click on Next.
Step 5
Select the location you want to save your project to and click on Create.
Step 6
Now you will see only two Objective-C Classes which were automatically generated by XCode. In the Empty Application never generate a UIViewController class; if you want, you can create it manually.
1.Appdelegate.h
2.AppDelegate.m
Here we write code....
Appdelegate.h
Appdelegate.m
Here is the code where we change the color:
Step 7
Now select in which Platform you want to see the output.
Output
Output 1 in iPhone:
Output 2 in iPhone:
Output 1 in iPad:
Output 2 in iPad: