Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 323
pirey4 Avatar asked Oct 12 '10 23:10

pirey4


3 Answers

You can change font property after show method(like showFromBarButtonItem) as below.

CGRect oldFrame = [(UILabel*)[[sheet subviews] objectAtIndex:0] frame];
UILabel *newTitle = [[[UILabel alloc] initWithFrame:oldFrame] autorelease];
newTitle.font = [UIFont boldSystemFontOfSize:17];
newTitle.textAlignment = UITextAlignmentCenter;
newTitle.backgroundColor = [UIColor clearColor];
newTitle.textColor = [UIColor whiteColor];
newTitle.text = @"My Title";
[sheet addSubview:newTitle];

[sheet release];
like image 59
conecon Avatar answered Nov 13 '22 02:11

conecon


Like Nimrod said you can't do this with a native method. You could check the UIActionSheet subviews, find the good one and change its properties.

BUT

  • This implementation might crash in a futur iOS update
  • Apple may reject your app
  • UIActionSheet is a native element of iPhone GUI and users are familiar with it

SO

You really should don't change the font size used.. If this UIActionSheet title is important you should find another way to show it to the user...

like image 41
Francescu Avatar answered Nov 13 '22 00:11

Francescu


From the UIActionSheet Class Reference:

UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:.

like image 2
Justin Whitney Avatar answered Nov 13 '22 00:11

Justin Whitney