2013-10-30 2 views

답변

1

나는 내 방식이 최선이 아니라고 생각하지만, 어쨌든 :

- (void)render 기능에 I 교체 (추가 linkShouldBe_regularFont 속성을

else if ([component.tagLabel caseInsensitiveCompare:@"a"] == NSOrderedSame) 
     { 
      if (self.currentSelectedButtonComponentIndex==index) 
      { 
       if (self.selectedLinkAttributes) 
       { 
        [self applyFontAttributes:self.selectedLinkAttributes toText:attrString atPosition:component.position withLength:[component.text length]]; 
       } 
       else 
       { 
         [self applyBoldStyleToText:attrString atPosition:component.position withLength:[component.text length]]; 
        [self applyColor:@"#FF0000" toText:attrString atPosition:component.position withLength:[component.text length]]; 
       } 
      } 
      else 
      { 
       if (self.linkAttributes) 
       { 
        [self applyFontAttributes:self.linkAttributes toText:attrString atPosition:component.position withLength:[component.text length]]; 
       } 
       else 
       { 
         [self applyBoldStyleToText:attrString atPosition:component.position withLength:[component.text length]]; 
        [self applySingleUnderlineText:attrString atPosition:component.position withLength:[component.text length]]; 
       } 
      } 

      NSString *value = [component.attributes objectForKey:@"href"]; 
      value = [value stringByReplacingOccurrencesOfString:@"'" withString:@""]; 
      [component.attributes setObject:value forKey:@"href"]; 

      [links addObject:component]; 
     } 

- 내 사용자 정의 속성, linkShouldBe_regularFont == YES 경우, 글꼴) 일반 될 것입니다 :

else if ([component.tagLabel caseInsensitiveCompare:@"a"] == NSOrderedSame) 
     { 
      if (self.currentSelectedButtonComponentIndex==index) 
      { 
       if (self.selectedLinkAttributes) 
       { 
        [self applyFontAttributes:self.selectedLinkAttributes toText:attrString atPosition:component.position withLength:[component.text length]]; 
       } 
       else 
       { 
        if (!self.linkShouldBe_regularFont) { 
         [self applyBoldStyleToText:attrString atPosition:component.position withLength:[component.text length]]; 
        } 
        [self applyColor:@"#FF0000" toText:attrString atPosition:component.position withLength:[component.text length]]; 
       } 
      } 
      else 
      { 
       if (self.linkAttributes) 
       { 
        [self applyFontAttributes:self.linkAttributes toText:attrString atPosition:component.position withLength:[component.text length]]; 
       } 
       else 
       { 
        if (!self.linkShouldBe_regularFont) { 
         [self applyBoldStyleToText:attrString atPosition:component.position withLength:[component.text length]]; 
        } 
        [self applySingleUnderlineText:attrString atPosition:component.position withLength:[component.text length]]; 
       } 
      } 

      NSString *value = [component.attributes objectForKey:@"href"]; 
      value = [value stringByReplacingOccurrencesOfString:@"'" withString:@""]; 
      [component.attributes setObject:value forKey:@"href"]; 

      [links addObject:component]; 
     } 
+0

아래의 링크 속성 솔루션이 올바른 것이어야합니다. – jyek

2

linkAttributes 속성은 링크의 사용자 정의 스타일을 사용할 수 있습니다. linkAttributes을 빈 사전으로 설정하면 링크의 스타일이 지정되지 않습니다.

// Remove all link styles 
descriptionSourceLabel.linkAttributes = @{}; 

// To change only i.e. link color 
descriptionSourceLabel.linkAttributes = @{@"color": @"red"};