Skip to content

Instantly share code, notes, and snippets.

@naveedmcs
Created December 14, 2017 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naveedmcs/d32e5e1caa845f1acb85df912fd9ef3c to your computer and use it in GitHub Desktop.
Save naveedmcs/d32e5e1caa845f1acb85df912fd9ef3c to your computer and use it in GitHub Desktop.
label styling in at RunTime: Objective C
NSString * titleString = [itemLabels objectAtIndex:indexPath.row];
//create attributedstring object with intialize string
NSMutableAttributedString * attriStr = [[NSMutableAttributedString alloc]initWithString:titleString];
// formate style
[attriStr setColorForText:titleString withColor:BLUE_COLOR];
[attriStr setFontForText:titleString withFont:[UIFont fontWithName:@"RobotoCondensed-Regular" size:20]];
//redefine width
CGSize maximumSize = CGSizeMake(250, INT_MAX); // CGSizeMake(width,height).
CGRect lblFrame = cell.title_lbl.frame;
lblFrame.size.width = maximumSize.width;
cell.title_lbl.frame = lblFrame;
// assign object string to label
cell.title_lbl.attributedText = attriStr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment