Create User Defined Button For IPhone and IPad

Introduction

In this article we create two custom buttons designed by code. In other words in this we don't use Xib (XCode Interface builder) or Nib files. In this when we click on the first button (Purple color) it give its output on the second button (Red color) and when we click on the second button (Red color) it give its output on the first button (Purple color). I will explain how it works step-by-step here... 

Step 1

Open XCode using double-click on it.

Select-xcode-in-iphone.jpg

Step 2

Create a New XCode Project via 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 use userdefinedcontrol and Company Identifier Mcn Solutions and click on Next.

Project-name-in-iPhone.jpg

Step 5

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

save-project-location-in-iphone.jpg

Step 6

Now you will see only two Objective C Classes automatically generated by XCode. An Empty Application never generates a UIViewController class.

view-of-xcode-in-iphone.jpg

1.Appdelegate.h
2.AppDelegate.m

Here we write code....

1.Appdelegate.h

code-of-appdelegate.h-in-iPhone.jpg

2.Appdelegate.m

code-of-appdelegate.m-in-iPhone.jpg

Step 7

Now select which Platform you want to see output for.

Run-application-in-simulator-in-iphone.jpg

Output

Output 1 in iPhone:

Output1-in-iphone.jpg


Here click on the first button (Purple color).

Output 2 in iPhone:

Output2-in-iphone.jpg

Output "I Love" shows on the second button (Red color).

Output 3 in iPhone:

Output3-in-iphone.jpg

Here we click on the second button (Red color); it shows the output "INDIA" on the first button (Purple color). 

Output 1 in iPad
Output1-in-ipad.jpg
Here 
when we click on the second button (Red color) it gives its output on the first button (Purple color). 

Output 2 in iPad:
Output2-in-ipad.jpg
Output "INDIA" show on
 first button (Purple color).

Output 3 in iPad
Output3-in-ipad.jpg
Here we click on 
the first button (Purple color) it shows the output "I Love" on the second button (Red color).

Up Next
    Ebook Download
    View all
    Learn
    View all