gpt4 book ai didi

c# - xamarin ios c# 下划线 UIButton 文本

转载 作者:可可西里 更新时间:2023-11-01 04:41:08 25 4
gpt4 key购买 nike

我试图在这个 UIButton ("Privacy Policy") 中给文本加下划线。如何做到这一点?这是我的代码:

var PrivacyPolicy = new UIButton(new CGRect(10, s.MxHt - 40, (s.MxWd - 20) / 3, 30));

PrivacyPolicy.BackgroundColor = UIColor.FromRGB(0, 92, 191);
PrivacyPolicy.Font = UIFont.FromName("Roboto", 14f);
PrivacyPolicy.SetTitle("Privacy Policy", UIControlState.Normal);
PrivacyPolicy.TouchUpInside += HandleBtnOpenPrivacyTouchUpInside;

if (iPad == false)
{
PrivacyPolicy.Font = UIFont.SystemFontOfSize(12);
}

View.AddSubview(PrivacyPolicy);

最佳答案

另外,我发现这也很管用。谢谢!

        //Set attribute for underlineing information links
var underlineAttr = new UIStringAttributes { UnderlineStyle = NSUnderlineStyle.Single, ForegroundColor = UIColor.White };

//Privacy Button Link
var PrivacyPolicy = new UIButton(new CGRect(10, s.MxHt - 40, (s.MxWd - 20) / 3, 30));
PrivacyPolicy.BackgroundColor = UIColor.FromRGB(0, 92, 191);
PrivacyPolicy.Font = UIFont.FromName("Roboto", 14f);
PrivacyPolicy.SetAttributedTitle(new NSAttributedString("Privacy Policy", underlineAttr), UIControlState.Normal);
PrivacyPolicy.TouchUpInside += HandleBtnOpenPrivacyTouchUpInside;
if (iPad == false) { PrivacyPolicy.Font = UIFont.SystemFontOfSize(12); }
View.AddSubview(PrivacyPolicy);

关于c# - xamarin ios c# 下划线 UIButton 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34021610/

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