From b8e94316e41eba72d927d5ca7d931b26139ee8ff Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期一, 15 六月 2020 09:12:53 +0800 Subject: [PATCH] 20200612 --- Shared.IOS/UI/Button.cs | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Shared.IOS/UI/Button.cs b/Shared.IOS/UI/Button.cs index 4cba332..a4f1528 100644 --- a/Shared.IOS/UI/Button.cs +++ b/Shared.IOS/UI/Button.cs @@ -23,12 +23,32 @@ } } + + // string PingFangSCRegular = "Helvetica"; + //string PingFangSCSemibold = "Helvetica-Bold"; + + /// <summary> + /// 鏅�氬瓧浣� + /// </summary> + public string FontNameNormal = "PingFangSC-Regular"; + /// <summary> + /// 绮椾綋 + /// </summary> + public string FontNameBold = "PingFangSC-Semibold"; + + + /// <summary> /// Initializes a new instance of the <see cref="Shared.Button"/> class. /// </summary> public Button() { iosButton = new MyButton(this) { }; + if (Application.IsUsePingFang) + { + FontName = FontNameNormal; + } + iosButton.TitleLabel.Font = UIFont.FromName(FontName, Application.FontSize); } @@ -87,7 +107,11 @@ return iosButton.TitleLabel.Font.Name; } set{ - iosButton.TitleLabel.Font = UIFont.FromName(value, iosButton.Font.PointSize); + try + { + iosButton.TitleLabel.Font = UIFont.FromName(value, iosButton.Font.PointSize); + } + catch { } } } @@ -116,11 +140,11 @@ isBold = value; if (isBold) { - iosButton.TitleLabel.Font = UIFont.FromName("Helvetica-Bold", mTextSize); + iosButton.TitleLabel.Font = UIFont.FromName(FontNameBold, mTextSize); } else { - iosButton.TitleLabel.Font = UIFont.FromName("Helvetica", mTextSize); + iosButton.TitleLabel.Font = UIFont.FromName(FontNameNormal, mTextSize); } } } @@ -434,7 +458,7 @@ set; } - class MyButton : UIKit.UIButton + public class MyButton : UIKit.UIButton { [Weak] View view; public MyButton(View view) -- Gitblit v1.8.0