Change fontSize on a UIAlertView?

Discussion in 'iOS Programming' started by Danneman101, Feb 26, 2009.

  1. Danneman101
    Expand Collapse
    macrumors 6502

    Joined:
    Aug 14, 2008
    #1
    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...
     
  2. dejo
    Expand Collapse
    Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    I don't believe you can. Why do you need to? I.E. what are you trying to do?
     
  3. Danneman101
    Expand Collapse
    thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #3
    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.
     
  4. dejo
    Expand Collapse
    Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    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.
     
  5. Danneman101
    Expand Collapse
    thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #5
    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?
     
  6. dejo
    Expand Collapse
    Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    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,
    Code:
    @interface MyAlertView: UIAlertView { }
    
    - (void)drawRect:(CGRect)rect
    {
         // custom drawing goes here
    }
    
     
  7. Danneman101
    Expand Collapse
    thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #7
    Alright, that sounds like a good way to solve this. Thanks for your help, dejo - much appreciated :)
     

Share This Page