Open DeerSteak opened 6 years ago
I believe the original creator has long abandoned this project.
For readability, instead of wrapping multiple statements in the IF, invert the it and return:
try
{
var label = (UILabel)Control;
var text = (NSMutableAttributedString)label.AttributedText;
if (text == null) return;
var range = new NSRange(0, text.Length);
if (underlined)
{
text.AddAttribute(UIStringAttributeKey.UnderlineStyle, NSNumber.FromInt32((int)NSUnderlineStyle.Single), range);
}
else
{
text.RemoveAttribute(UIStringAttributeKey.UnderlineStyle, range);
}
}
@JungleJ0n + @DeerSteak: Underline is now implemented in Xamarin Forms :) https://github.com/xamarin/Xamarin.Forms/pull/2221 It will be available soonish :)
First of all, thanks for this tutorial. I've found multiple effects to be useful in my work.
In the iOS portion of the effect, this section results in a NullReferenceException:
I'm not familiar with github (I work in an all-Microsoft environment so I'm really only familiar with TFS) so I don't know how to send a pull request, but I wrapped that whole section in
And that made the issue go away. Since the label has been discarded, there's no reason to go through the un-underlining process.