Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

There is a possibility to add images (to be exact: icons or symbols) to the buttons of a UIActionSheet (or a UIAlertView) without loading image files or fiddling around with (sub)views. In these classes buttons are specified by their titles, which are strings. So it is obvious to use symbols, which one can specify also by strings. The first I came up with was using unicode symbols.

Then I discovered that several of them are rendered as nice icons on iOS and as one can see for several symbols in the Character Viewer on Mac OS, too. Thus, the symbols can be used actually everywhere a string can be specified.

The drawbacks of this approach are:

  • You are limited to predefined symbols.
  • Not all symbols are rendered as they should (e.g. \u29C9).
  • There can be changes in the appearance of some symbols on different iOS versions (e.g. \U0001F533 on iOS 5 and 6).

Here are some interesting symbols among others:

  • Miscellaneous Symbols and Pictographs
  • Miscellaneous Symbols
  • Transport and Map Symbols
  • Dingbats

If you want to quickly check how a symbol looks like (at least on Mac OS), you can use the Calculator. Check definitely in the simulator: For instance \u2B1C is not an icon in Calculator 10.7.1.

Screenshots:

UIActionSheet

UIActionSheet

Button titles:

@"\U0001F6A9 \U0001F4CC \u26F3 \u2690 \u2691 \u274F \u25A4 Test"
@"\U0001F4D6 \U0001F30E \U0001F30F \u25A6 \U0001F3C1 \U0001F332 \U0001F333 \U0001F334 Test"

UIAlertView

enter image description here

Button title:

@"\u26A0 Yes"

UITableViewCell with checkbox and other icons

UITableViewCell

Leave a Comment