mcconkiee
3/31/2014 - 9:30 PM

font awesome as uilabel

font awesome as uilabel

//assumes FontAwesome.ttf is a resource and added to plist 

NSInteger ti = (NSInteger)self.quizDuration ;
NSInteger seconds = ti % 60;
NSInteger minutes = (ti / 60) % 60;
NSInteger hours = (ti / 3600);
NSString *TTLE = [NSString stringWithFormat:@"%02li:%02li:%02li   ", (long)hours, (long)minutes, (long)seconds];

//f01d = play
//f04c = pause
int sze = 15;
unichar symbol = 0xf04c;//play (fontawesome)
UIButton *bt = (UIButton*)self.navigationItem.titleView;
UIColor *clr = [UIColor whiteColor];
if (!self.quizTimer) {
    symbol = 0xf01d;
    clr = [UIColor applicationOrangeColor];
}
TTLE = [TTLE stringByAppendingString:[NSString stringWithFormat:@"%C",symbol]];
NSMutableAttributedString *aTTLE = [[NSMutableAttributedString alloc] initWithString:TTLE
                                                                          attributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                                      [UIFont applicationFontOpenSansBold:sze],NSFontAttributeName,
                                                                                      clr,NSForegroundColorAttributeName
                                                                                      , nil]];

[aTTLE setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                      [UIFont fontWithName:@"FontAwesome" size:15],NSFontAttributeName,
                      clr,NSForegroundColorAttributeName
                      , nil]
               range:NSMakeRange(TTLE.length - 1, 1)];

[bt setAttributedTitle:aTTLE forState:UIControlStateNormal];