Slide 42
Slide 42 text
Emphasizing a range
Creating Multi-style String
•Using NSForegroundColorAttributeName
NSMutableAttributedString *string = [[NSMutableAttributedString alloc]
! ! initWithString:@”Dentist at 9:15am.”
! ! attributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:12.0f }];
[string addAttribute:NSForegroundColorAttributeName
! ! value:[UIColor redColor]
! ! range:NSMakeRange(11, 6)]; // Change the time, 9:15am, to red
Dentist at 9:15am.
•Using NSForegroundColorAttributeName
NSMutableAttributedString *string = [[NSMutableAttributedString alloc]
! ! initWithString:@”Dentist at 9:15am.”
! ! attributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:12.0f }];
[string addAttribute:NSForegroundColorAttributeName
! ! value:[UIColor redColor]
! ! range:NSMakeRange(11, 6)]; // Change the time, 9:15am, to red