New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[attributedlabel] Allow linkColor to be ignored when nil. #337

Merged
merged 1 commit into from Feb 14, 2013

Conversation

Projects
None yet
2 participants
@netsgnut
Contributor

netsgnut commented Feb 1, 2013

I have recently encountered a project where the links in attributed label have to be styled in different color. However, it seems that if it is a link, the color that is specified through setLinkColor: takes precedence over setTextColor:range:.

In the local copy of nimbus in that project, a change was made to ignore linkColor if it is nil. Therefore, one could specify different colors of links as follows:

NIAttributedLabel *labelView = [[NIAttributedLabel alloc] init];
[labelView setLinkColor:nil];

[labelView setText:@"Hello Nimbus!"];
[labelView addLink:[NSURL URLWithString:@"http://example.com/"] range:NSMakeRange(0, 5)];
[labelView setTextColor:[UIColor redColor] range:NSMakeRange(0, 5)];
[labelView addLink:[NSURL URLWithString:@"http://nimbuskit.info/"] range:NSMakeRange(6, 6)];
[labelView setTextColor:[UIColor brownColor] range:NSMakeRange(6, 6)];

I am not sure if it is useful to others, nor if there is another better way of doing this (a flag for global ignore of link styles perhaps?). Please kindly review and see if it is appropriate. Thanks!

jverkoey added a commit that referenced this pull request Feb 14, 2013

Merge pull request #337 from netsgnut/attributedlabel-optional-linkcolor
[attributedlabel] Allow linkColor to be ignored when nil.

@jverkoey jverkoey merged commit f24e53d into jverkoey:master Feb 14, 2013

@jverkoey

This comment has been minimized.

Show comment
Hide comment
@jverkoey

jverkoey Feb 14, 2013

Owner

Definitely useful, thanks!

Owner

jverkoey commented Feb 14, 2013

Definitely useful, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment