我想强调xamarin iOS中的按钮文本,我有一个名为
的样式 public static UIButton StyleLinkButtonBlack(this UIButton button)
{
button.Font = Styles.SetOpenSansSemiboldFont(Dimensions.medium);
button.LineBreakMode = UILineBreakMode.WordWrap;
button.SetTitleColor(UIColor.Black, UIControlState.Normal);
button.TitleLabel.TextAlignment = UITextAlignment.Center;
return button;
}
我如何实现这一目标?
答案 0 :(得分:1)
只需要添加一个NSMutableAttributedString,就像那样
var attrString = new NSMutableAttributedString(button.TitleLabel.Text);
attrString.AddAttribute(UIStringAttributeKey.UnderlineStyle,NSNumber.FromInt32((int)NSUnderlineStyle.Single),new NSRange(0, attrString.Length));
button.TitleLabel.AttributedText = attrString;