Alex Rivera | Logout

Is there any way to change the title font size in a UIActionSheet?

Asked 2010-10-12T23:47:14.217
9

The font is very small and hard for some to read so I'd like to make it closer to the font size used on the buttons below it.

Edit
Report

2 Answers

2

@user651909's answer works great for me, although just to add a few more details:

I had to initWithTitle:@" " (note the non-empty string) when creating the UIActionSheet so that the view had some space on top for any text to begin with. Then, after doing a [popupQuery showInView:self.view];, I added his suggestion so that the oldFrame would be initialized. Finally, I added:

[newTitle sizeToFit];
newTitle.frame = CGRectMake(oldFrame.origin.x, 
                            oldFrame.origin.y, 
                            oldFrame.size.width, 
                            newTitle.frame.size.height);

This was necessary since the oldFrame's height was too small for my larger font (size 20), causing some letters to get clipped on the bottom. Also even with this tweak, if you make the text too big, say greater than boldSystemFontOfSize:26, the text will run too close or into the buttons below. Resizing the sheet's frame doesn't help since the buttons appear to be anchored to the top.

Presumably doing

CGRect oldFrame = [(UILabel*)[[sheet subviews] objectAtIndex:0] frame]; 

doesn't violate Apple's policy of not using any internal API, right?

answered 2011-11-18T02:00:08.933
0

Well, there is a way to do it - I created a UIActionSheet subclass on github named LTActionSheet

As others mentioned, all kinds of dire things may happen if you use it (I have not in shipping code ... yet :-) ) If you use it in an app that gets accepted, please let us all know!

answered 2011-08-04T15:31:03.090

Your Answer