Custom UIAlertView?

点点圈 提交于 2020-01-01 08:47:09

问题


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


回答1:


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

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




回答2:


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




回答3:


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.




回答4:


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




回答5:


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




回答6:


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




回答7:


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



来源:https://stackoverflow.com/questions/6853124/custom-uialertview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!