How To Change Background Color After Pressing Button In iPhone

How to Change background color after pressing Button in iPhone

In this application we will see how to change background color using button pressed. So let see how it will worked.  My previous post you can find out from here  ButtonPressed

Step 1: Open the Xcode, Create a new project using View Base application. Give the application “BackgroundColor”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Open the BackgroungColorViewController.h file and make the following changes in the file

 

 

 

Step 4: Double click the BackgroungColorViewController.xib file and open it to the Interface Builder. First drag the three Round Rect Button and place it to the view window. Select the first button and bring up Connection Inspector and connect Touch Up Inside to the Files Owner icon and select FirstButtonPressed: method. Do the same thing for other two buttons and select SecondButtonPressed: and ThirdButtonPressed: method. Now save the .xib file, close it and go back to the Xcode.

Step 5: In the BackgroungColorViewController.m file make the following changes:

 

 

 

Step 6: Now compile and run the application on the simulator.

You can Download SourceCode from here BackgroungColor

Comments 2

  1. it is very easy to the iphone developer to grasp the coding and analyze through ur website i had got many sample coding through ur website and it made me easier to develop the code for my projects,so please post as many as codings
    that make a developer or learner easier.

    PAVAN KUMAR R.M.

  2. Hi! I was doing well and have all the codes in this example. The problem is I cannot connect the buttons. When I try to connect the buttons according to these instructions:
    “and select FirstButtonPressed: method. Do the same thing for other two buttons and select SecondButtonPressed: and ThirdButtonPressed: method. Now save the .xib file, close it and go back to the Xcode.”
    There is nothing to connect inside File’s Owner Icon.
    How can I fix this?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">