Customizing UIAlertView

橙三吉。 提交于 2019-11-26 17:48:43

I think your best bet is to forget customizing UIAlert view and build a custom view yourself.

For one, what you're showing really isn't an "alert" so it's counter to what UIAlertView is designed to be for. This means that you're changing the UI paradigm on the user which is never a good idea.

Second, it would be much easier to animate a custom view into place than to try and hack UIAlertView to get it to do what you want.

First you need to make the alert box bigger to accomodate your controls, yet it has to be placed at the center.

For this, instead of setting the frame size, your the message text with "\n"s as necc. e.g.:

alert = [[UIAlertView alloc] initWithTitle:@"Rate this picture."
message:@"Tap a star to rate.\n\n\n\n " /*------ look at here!!----*/
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];

Then use a UIAlertViewDelegate for the alertview.

override its, viewWillAppear: add your buttons and set their frames manually at desired position.

OR: create a entire view with a view controller, and add the view to the alert box like:

[myalertview addSubvew:mycomplexalert];

Hope this will come into your help :)

I am using alert boxes for rating input with star images,twitter,fb feedback etc.

UPDATE iOS7:

For iOS 7, create your own view with components and set it as the alertview's accessory view:

[alert setValue:imageView forKey:@"accessoryView"]; 

Its thats simple :-)

This tutorial covers how to subclass UIAlertView to achieve an input text box. It explains how to enlargen the view, add subviews (like text boxes or images) and make a transform to move the box up higher on the screen.

I wrote a almost pixel perfect UIAlertView replacement, that's also fully configurable. Have a look at CODialog if it fits your needs.

There are no in-built components for this. UIAlertView should just have text and buttons as per the HIG document.

You will have to create your own view and add controls to it. The HeadsUpUI example in the SDK shows how to show a custom menu-like view as an overlay.

Hope that helps.

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