Created
April 24, 2017 11:32
-
-
Save Stayrony/c9280bb2e4ce161fd45320bb26edf30a to your computer and use it in GitHub Desktop.
Xamarin iOS Letter Spacing Label Renderer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnElementChanged(ElementChangedEventArgs<Label> e) | |
{ | |
base.OnElementChanged(e); | |
var data = Element as LetterSpacingLabel; | |
if (data == null || Control == null) | |
{ | |
return; | |
} | |
var text = Control.Text; | |
var attributedString = new NSMutableAttributedString(text); | |
var nsKern = new NSString("NSKern"); | |
var spacing = NSObject.FromObject(data.LetterSpacing * 10); | |
var range = new NSRange(0, text.Length); | |
attributedString.AddAttribute(nsKern, spacing, range); | |
Control.AttributedText = attributedString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment