UIActionSheet Change arrow position?

lbadias picture lbadias · Sep 21, 2010 · Viewed 8.9k times · Source

To show a UIActionSheet on the iPad I did this:

[actionSheetX showFromRect:RectX inView:myView animated:YES];

The arrow of the popover points down, can I change this position to point left, up or right, like when using a normal popover?

Answer

overboming picture overboming · Jan 1, 2012

Apple doesn't provide any access to internal structure for UIActionSheet's internal implementation of showFromRect, but as for arrow direction, there is actually a very hack-y way to work around this and sort of being able to change arrow direction to a desired direction.

Trick is to mess around the rect parameter in - (void)showFromRect:(CGRect)rect inView (UIView *)view animated:(BOOL)animated. Apple doesn't document this rect parameter very well, but if your original rect will give you a down arrow direction, feed in a rect with a large height and negative number origin.y will kind of push the action sheet popover all the way up thus showing a upward arrow direction. This is a extreme hack but it works consistently across firmware. Hope it helps.