编程语言
首页 > 编程语言> > xamarin ios c#强调UIButton文本

xamarin ios c#强调UIButton文本

作者:互联网

我试图强调这个UIButton(“隐私政策”)中的文字.如何实现这一目标?这是我的代码:

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,ios,visual-studio,uibutton,xamarin
来源: https://codeday.me/bug/20190623/1271293.html