title: Setting italic text for a certain portion of the text in iOS
body: <p>I am using TTTAttributedLabel(<a href="https://github.com/mattt/TTTAttributedLabel" rel="nofollow">https://github.com/mattt/TTTAttributedLabel</a>) and using it to set the italic text for those in the parentheses. The problem is the text in the parentheses is not set to italic. Not sure where my error is..</p>
  
  <p>The code looks like this:</p>
  
  <pre><code>static inline NSRegularExpression * ParenthesisRegularExpression() {
      static NSRegularExpression *_parenthesisRegularExpression = nil;
  
      static dispatch_once_t onceToken;
      dispatch_once(&amp;onceToken, ^{
          _parenthesisRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"\\([^\\(\\)]+\\)" options:NSRegularExpressionCaseInsensitive error:nil];
      });
  
      return _parenthesisRegularExpression;
  }
  
  -(TTTAttributedLabel*)setItalicTextForLabel:(TTTAttributedLabel*)attributedLabel fontSize:(float)Size stringToBeSet:(NSString*)string
  {
      [attributedLabel setText:string afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString)
      {
          NSRange stringRange = NSMakeRange(0, [mutableAttributedString length]);
          NSRegularExpression *regexp = ParenthesisRegularExpression();
          [regexp enumerateMatchesInString:[mutableAttributedString string] options:0 range:stringRange usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
              UIFont *italicSystemFont = [UIFont italicSystemFontOfSize:Size];
              CTFontRef italicFont = CTFontCreateWithName((__bridge CFStringRef)italicSystemFont.fontName, italicSystemFont.pointSize, NULL);
              if (italicFont) {
                  [mutableAttributedString removeAttribute:(NSString *)kCTFontAttributeName range:result.range];
                  [mutableAttributedString addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)italicFont range:result.range];
                  CFRelease(italicFont);
  
                  [mutableAttributedString removeAttribute:(NSString *)kCTForegroundColorAttributeName range:result.range];
                  [mutableAttributedString addAttribute:(NSString*)kCTForegroundColorAttributeName value:(id)[[UIColor grayColor] CGColor] range:result.range];
              }
          }];
  
          return mutableAttributedString;
      }];
      return attributedLabel;
  }
  </code></pre>
  
  <p>I am calling it this way:<code>mylabel = [self setItalicTextForLabel:descriptionLabel fontSize:23 stringToBeSet:string];</code></p>
  
  <p>Need some guidance on what I am doing wrong.</p>