我认为我的方式不是最好的,但无论如何:
在
- (void)render
功能
我代替:
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财产 - 我的自定义属性,如果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];
}
下面的链接属性解决方案应该是正确的 – jyek