Created
December 14, 2017 12:10
-
-
Save naveedmcs/d32e5e1caa845f1acb85df912fd9ef3c to your computer and use it in GitHub Desktop.
label styling in at RunTime: Objective C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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