假设我有一个显示文本的UITextView:
电子邮件:jon.smith@test.com
如何加粗给定UITextView的某些部分(本例中为电子邮件)?我用以下代码粗体化了整个UITextView:
customLabel.Font = UIFont.FromName("Helvetica-Bold", 20f);
但我如何加粗某些部分?
答案 0 :(得分:1)
var bold = new UIStringAttributes {
Font = UIFont.FromName("Helvetica-Bold", 20f)
};
var email = new NSMutableAttributedString ("E-mail: jon.smith@test.com");
email.SetAttributes (bold.Dictionary, new NSRange (0, 6));
customLabel.AttributedText = email;