Bold font

Discussion in 'iOS Programming' started by rustywild, Mar 16, 2011.

  1. rustywild macrumors newbie

    Joined:
    Mar 9, 2011
    #1
    Hi:

    I have this line:
    case 0: myList = [NSArray arrayWithObjects: @"cars",@"balls";

    how can I put "cars" in bold font??, only "cars"


    thanx
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    You would need to take care of that when you go to display those strings in your UI. So, how are you showing these values on the screen?

    P.S. You may want to review that line for syntax errors. It should, at least, be generating warnings during compile.
     
  3. rustywild thread starter macrumors newbie

    Joined:
    Mar 9, 2011
    #3
    line has no errors.

    cars are shown in UITableView

    i need to put in bold
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Then the line you have in your code is not the same as the one you provided. It's always a good idea to paste the actual code in order to reduce confusion.

    By default, for a non-customized table cell, I believe the textLabel is shown in bold.
     
  5. rustywild thread starter macrumors newbie

    Joined:
    Mar 9, 2011
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Not sure what you mean by "make out". Please elaborate.
     
  7. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #7
    It's always best to design your tableview data model so it contains the info needed for display so that there's a minimum of special-case code. Obviously a simple list of strings isn't enough to describe your data. You need a data object for each row. And in that data object you can put a font or you can put a flag that indicates bold/not bold. Then in your cellForRowAtIndexPath you check that value and make the label bold or not bold.

    As a start I'd use an array of dictionaries. For each row dictionary I'd add the title and a boolean flag that indicates bold/not bold.
     
  8. rustywild, Mar 16, 2011
    Last edited by a moderator: Mar 16, 2011

    rustywild thread starter macrumors newbie

    Joined:
    Mar 9, 2011
    #8
    Can you ut me q example??


    thanx

    make out or highlight maybe
     
  9. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #9
    Wikipedia definition for make out. I seriously don't think this is what you mean...

    Perhaps you mean emphasise?
     
  10. rustywild thread starter macrumors newbie

    Joined:
    Mar 9, 2011
    #10
    Yes, yes, sorry for my language
     
  11. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #11
    Not quite sure what the translation of that is into English but I'll give you some psuedo code.

    Code:
    // viewDidLoad
    // build the data model
    NSMutableArray* rowArray = ;
    self.rowArray = rowArray;
    
    NSDictionary* rowDictionary = [NSDictionary dictionaryWithObjectsAndKeys: @"cars", kTitleKey, [NSNumber numberWithBool:YES], kBoldFontKey, nil];
    [rowArray addObject:rowDictionary];
    
    rowDictionary = [NSDictionary dictionaryWithObjectsAndKeys: @"balls", kTitleKey, [NSNumber numberWithBool:NO], kBoldFontKey, nil];
    [rowArray addObject:rowDictionary];
    
    // cellForRowAtIndexPath
    // display the model object for this row
    NSDictionary* rowDictionary = [self.rowArray objectAtIndex:row];
    cell.titleLabel.text = [rowDictionary objectForKey:kTitleKey];
    if ([[rowDictionary objectForKey:kBoldFontKey] boolValue])
      cell.titleLabel.font = some bold font;
    else
      cell.titleLabel.font = some non-bold font;
     
  12. rustywild thread starter macrumors newbie

    Joined:
    Mar 9, 2011
    #12

    A lot of thanx !!

    i'm going to check.
     

Share This Page