Tuesday, February 12, 2013

Custom AlertView in iphone

Few days back ,  i was developing an application ,  i had used very kinds of color in it . That made the app look very good.
But the only thing that mattered was the UIAlertView provided by Apple . That alertView made the app not look good whenever it popped up.

So , I decided to make a simple custom alertView for my app

Here is the code

I made Button in the appDelegate and whenever a user clicks on it , it will show up a Popup of our custom AlertView
and in the application:didFinishLaunchingWithOption:  method , i added the following code


and then i made a selector function "clicked" for clickAction of Button

And now comes the development of the custom AlertView  called "ConfirmationAlertView"

In the .h file ,modify as following


We will 'title' for title for alertView and 'statement' for its message
Also , we need an imageView for holding the logo and another for holding the 'line' image

In the .m file , modify as following







i made a view of size of window and then i added another popupView to it .
We have applied colorGradient from white to gray as iot looks good
For making customization in the look of button , we have made changes in its layer


this is how our show method looks

Transformation means mapping of one coordinate systems into another coordinate systems
ans alpha determines degree of its transparency 0.0 denotes transparent and 1.0 denotes opaque
we will make animations and committ them

same is our hide method




Finally , run the application in simulator , u will get the following result


well , you are done !
Thanks !!