I would like to underline the text in a UILabel. I have found following code for ObjC:
NSDictionary *underlineAttribute = @{NSUnderlineStyleAttributeName: @1}
myLabel.attributedText = [[NSAttributedString alloc] initWithString:@"Test string"
attributes:underlineAttribute];
I'm trying to port this to C# but it's not working. I'm trying the following:
var keys = new object[] { "NSUnderlineStyleAttributeName" };
var objects = new object[] { 1 };
NSDictionary underlineAttribute = NSDictionary.FromObjectsAndKeys(objects, keys);
label.AttributedText = new NSAttributedString(@"Test",underlineAttribute);
Instead of 1, I also tried "1" and NSUnderlineStyle.Single, but nothing is working
Any ideas?
Thanks
Try this:
label.AttributedText = new NSAttributedString (
"Test",
underlineStyle: NSUnderlineStyle.Single);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With