9

Seeing as the blue doesn't go with my UI interface, im just wondering if there is a way to change the colour of the uialertview, or use a image instead. With all the buttons, 'dismiss' etc still there

Thanks

laaaa
  • 119
  • 1
  • 1
  • 6
  • you could present a modal/popover view maybe- just a thought? make it seem like an alert and make a dismiss button that dismisses it? – Jordan Brown Jul 28 '11 at 01:22
  • 1
    Would this work? It's still blue. https://github.com/kyoshikawa/ZPopoverController – Sum Jul 28 '11 at 01:37

7 Answers7

20

The fine folks at CodeCropper just put out an open-source control that lets you create custom alert views. It's awesome.

enter image description here

https://github.com/gpambrozio/BlockAlertsAnd-ActionSheets

sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
  • 1
    Problem with this project is that it uses ARC. You will get compile problems left and right if your project does not use ARC. I don't get why people use ARC? – Sam B Dec 14 '12 at 14:20
  • 5
    @SamBudda: ARC is fantastic. Either way, if you don't use ARC you can explicitly enable it per-file on the build phases tab in Xcode. http://stackoverflow.com/q/10523816/456851 – sudo rm -rf Dec 14 '12 at 17:59
  • 1
    @SamBudda, do you enjoy explicityly `retain/release`ing your objects? – brianSan Jan 05 '13 at 18:37
1

You could try presenting a Modal View Controller with a transparent background.

    ModalViewController *popupController = [[ModalViewController alloc] initWithNibName:@"ModalViewController" bundle:nil]; 
[self presentModalViewController:popupController animated:NO];  

Something like this for the ModalView (http://stackoverflow.com/questions/849458/transparent-modal-view-on-navigation-controller)

This way you can create a custom Alert, but it's really a modal view that you can customize

Sum
  • 4,369
  • 1
  • 22
  • 38
  • 7
    FYI watch out with this approach- presenting a view controller modally, even with a transparent background, will make the view behind it disappear, leaving a white background. It will probably not be the effect you're looking for. – kris Dec 31 '11 at 18:19
0

You could use CODialog. It's fully style-able and configurable.

0

Subclassing UIAlertView is not an option, this class is not intended to be subclassed and doing so might be a reason of app rejection.

Instead, you might try to go through all alert view's subviews or create your own class

In case you are going to create your own class, here's an example of how to fake UIAlertView:

http://iosdevtricks.blogspot.com/2013/04/creating-custom-alert-view-for-iphone.html

marika
  • 106
  • 4
  • you are right, here's a quote from Apple "The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified." So creating new class with similar functionality seems to be the only option – marika May 02 '13 at 00:20
0

If looking for custom alert view then it might help.

https://github.com/Pradeepkn/PKCustomAlertView/

Hope it helps some one.

No need of setting delegate. You will get call back once the action completes on same method. Enjoy :)

Custom Alert view

Table Alert view

PradeepKN
  • 617
  • 7
  • 10
0

You can either go through its subviews and change what you need to change, or subclass it. Because UIAlertView inherits from UIView you can use:

 myAlertView.subViews

and modify the views or subclass UIAlertView to create your custom AlertView. Here is a very good article on how to sublass UIAlertView to get whatever design/color you want.

Subclassing UIAlertView

Basically what you want to override is this method:

- (void) drawRect:(CGRect)rect 

Hope that helps.

Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
0

you can use a uiview instead of uialertview and can easily customize uiview according to your needs

Piyush Kashyap
  • 1,965
  • 1
  • 14
  • 16