Reader Level:
ARTICLE

How to Change Background Color in iPhone and iPad

Posted by Sachin Bhardwaj Articles | iOS November 02, 2012
In this article I will explain the procedure of changing the background color of a window in iPhone or iPad.
  • 0
  • 0
  • 5446
Download Files:
 

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.

Select-xcode-in-iphone.jpg

Step 2

Create a New XCode Project by clicking on it.

create-project-in-iphone.jpg

Step 3

Now select Empty Application and click on Next.

Empty-Application-in-iPhone.jpg

Step 4

Now give your Product Name. Here I give Background and Click on Next.

Project-name-in-iPhone.png

Step 5

Select the location you want to save your project to and click on Create.

save-project-location-in-iphone.jpg

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

code-of-AppDelegate.h-in-iPhone.png

Appdelegate.m

code-of-AppDelegate.m-in-iPhone.png

Here is the code where we change the color:

BackGround-color-code-in-iPhone.png

Step 7

Now select in which Platform you want to see the output.

Run-in-iPhone.png

Output

Output 1 in iPhone:

Output1-in-iPhone.png

Output 2 in iPhone:

Output2-in-iPhone.png

Output 1 in iPad:

Output1-in-iPad.png

Output 2 in iPad:

Output2-in-iPad.png

COMMENT USING

Trending up