redribben

mas2

Feb 2nd, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (NSMutableAttributedString *)infoText:(NSIndexPath *)indexPath {
  2.     NSArray *settingArray = [self getArray];
  3.     id specificSetting = [settingArray objectAtIndex:indexPath.row];
  4. //    [(BMSettings *)[settingArray objectAtIndex:indexPath.row] detail];
  5.     NSString *settingDetails = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%@", [specificSetting detail]]];
  6.     NSString *setToON = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%@", [specificSetting setOn]]];
  7.     NSString *setToOFF = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%@", [specificSetting setOff]]];
  8.  
  9. //    NSString *infoText = @"settingDetails \n\nTurned ON\n settingON \n\nTurned OFF\n settingOFF";
  10.    
  11.    
  12.     NSMutableAttributedString *infoText = [[NSMutableAttributedString alloc]
  13.                                            initWithString:[NSString stringWithFormat:@"%@ \n\n%@ \n\n%@", settingDetails, setToON, setToOFF]];
  14.    
  15.     [infoText addAttribute:NSFontAttributeName value:[UIFont preferredFontForTextStyle:UIFontTextStyleBody] range:[settingDetails rangeOfString:settingDetails]];
  16.     [infoText addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:[settingDetails rangeOfString:settingDetails]];
  17.     [infoText addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:[settingDetails rangeOfString:setToON]];
  18.     [infoText addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:[settingDetails rangeOfString:setToOFF]];
  19.    
  20. // ****************   code from PSY unadulterated to work with:***********
  21. //    [attributedString replaceCharactersInRange:[attributedString.string rangeOfString:@"%@"] withString:message];
  22. //  
  23.  
  24.  
  25. return infoText;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment