我認爲我的方式不是最好的,但無論如何:
在
- (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