gpt4 book ai didi

ios - 如何在 Xamarin iOS 中为标题添加下划线

转载 作者:行者123 更新时间:2023-11-28 23:58:39 25 4
gpt4 key购买 nike

我想在 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;
}

我怎样才能做到这一点?

最佳答案

只需要添加一个 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;

关于ios - 如何在 Xamarin iOS 中为标题添加下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50332965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com