Changing the font of a button

Discussion in 'iOS Programming' started by Cdub16, Nov 1, 2010.

  1. Cdub16 macrumors member

    Joined:
    May 30, 2008
    #1
    I am trying to change the font of a title in a button.
    i have tried changing it in interface builder and in my code with:

    Code:
    button.titleLabel.font = [UIFont fontWithName:name size:size]
    but when i run my application the text always just comes up as the default
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  3. Cdub16 thread starter macrumors member

    Joined:
    May 30, 2008
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    How have you loaded the "Chalkduster" font, have you verified the name against UIFont's fontNameForFamily, and what iOS version are you trying to test against?
     
  5. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #5
    In what method are you setting the font? and what is the value of button at that time?
     
  6. Cdub16 thread starter macrumors member

    Joined:
    May 30, 2008
    #6
    actually i got the button thing to work i thought i had the font loaded but i didnt.

    but now it isn't working for a label.

    all im using is:
    Code:
    label.font = [UIFont fontWithName:@"chalkdust" size:36];
    the "chalkdust" worked for the button, why isnt it working for a uilabel?
     
  7. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #7
    Is the font name "chalkdust" (your post today) or "Chalkduster" (your post yesterday)?
     
  8. Cdub16 thread starter macrumors member

    Joined:
    May 30, 2008
    #8
    it is chalkdust.
    i downloaded another one
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    So,
    Code:
    button.titleLabel.font = [UIFont fontWithName:@"chalkdust" size:36];
    works but
    Code:
    label.font = [UIFont fontWithName:@"chalkdust" size:36];
    doesn't?
     
  10. Cdub16 thread starter macrumors member

    Joined:
    May 30, 2008
  11. dejo, Nov 2, 2010
    Last edited: Nov 3, 2010

    dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
    Then, that indicates a problem with your label instance variable. Tell us more about its declaration, setting, etc.
     
  12. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #12
    Check whether label is nil or non-nil at the time it's assigned a font. Maybe the variable isn't connected to the nib correctly, or the label.font is occurring at the wrong time.
     

Share This Page