PDA

View Full Version : Change fontSize on a UIAlertView?




Danneman101
Feb 26, 2009, 01:23 PM
Does the UIAlertView support changing its fontsize, and if so what method should I use?

Ive tried systemFontOfSize, for instance, but it seems not to be a UIAlertView-property...



dejo
Feb 26, 2009, 03:03 PM
Does the UIAlertView support changing its fontsize, and if so what method should I use?
I don't believe you can. Why do you need to? I.E. what are you trying to do?

Danneman101
Feb 26, 2009, 05:17 PM
Well, Im constructing a text-intensive app so Ive implemented a fontsize-modifier in the settings which works fine for most text. There are a total of 5 fontsizes: 12, 14, 16, 18 and 20 px.

However, the standard fontsize for the uialertview seem to be 16, which is fine, I guess. But since I use a fair amount of alerts in my app (for help-sections) it kind of breaks the homogeneity of the layout when the user has an other fontsize as standard.

dejo
Feb 26, 2009, 05:46 PM
Well, if you need that much control, you may need to consider subclassing UIAlertView (or UIActionSheet) or maybe even UIView to achieve the customization you desire.

Danneman101
Feb 27, 2009, 07:59 AM
When you say subclassing in this context, do you mean for instance adding a textview (or some other class that gives you control over the text-content) to the uialertview?

dejo
Feb 27, 2009, 09:27 AM
When you say subclassing in this context, do you mean for instance adding a textview (or some other class that gives you control over the text-content) to the uialertview?
No, I mean subclassing as in: creating a new class with the other class as the parent, and then overriding the appropriate methods as necessary to achieve what you are after: For example,
@interface MyAlertView: UIAlertView { }

- (void)drawRect:(CGRect)rect
{
// custom drawing goes here
}

Danneman101
Mar 1, 2009, 12:49 PM
Alright, that sounds like a good way to solve this. Thanks for your help, dejo - much appreciated :)