UIAlertView text formatting

2019-08-18 16:07发布

问题:

Hi I was wondering if it is possible to change the text formatting of the uialertview. i.e

The message "You have won" but with the "won" word in bold.

I looked around and it seems that the only solution is for me to create my own popup.

any ideas?

Thanks

回答1:

This isn't possible at present. You'd have to create a custom UIAlertView. That's the only option as it is not to be subclassed.

From the Class Reference:

Subclassing Notes
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.

There are open source versions out there though. Have a search on "Custom UIAlertView" and you'll easy find them. For example see this question for some links:

Custom UIAlertView?