From af4101b1d8461331bc3163b738fc75d4bf67c85c Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 28 七月 2020 17:47:44 +0800
Subject: [PATCH] 2020-07-28-1
---
Shared.IOS/UI/Button.cs | 87 +++++++++++++++++++++++++++++++++++++------
1 files changed, 75 insertions(+), 12 deletions(-)
diff --git a/Shared.IOS/UI/Button.cs b/Shared.IOS/UI/Button.cs
index f029376..a4f1528 100644
--- a/Shared.IOS/UI/Button.cs
+++ b/Shared.IOS/UI/Button.cs
@@ -2,6 +2,7 @@
using Foundation;
using Shared.IO;
using System;
+using CoreGraphics;
namespace Shared
{
@@ -22,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);
}
@@ -86,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 { }
}
}
@@ -101,6 +126,42 @@
}
/// <summary>
+ /// 鏄惁鏄剧ず绮椾綋
+ /// </summary>
+ bool isBold;
+ public bool IsBold
+ {
+ get
+ {
+ return isBold;
+ }
+ set
+ {
+ isBold = value;
+ if (isBold)
+ {
+ iosButton.TitleLabel.Font = UIFont.FromName(FontNameBold, mTextSize);
+ }
+ else
+ {
+ iosButton.TitleLabel.Font = UIFont.FromName(FontNameNormal, mTextSize);
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇瀛椾綋闀垮害
+ /// </summary>
+ public int GetTextWidth()
+ {
+ int textWidth = 0;
+ CGSize fontSize = this.Text.StringSize(iosButton.TitleLabel.Font);
+ textWidth = (int)fontSize.Width;
+
+ return textWidth;
+ }
+
+ /// <summary>
/// 鍒涙柊闇�瑕佸垱鏂扮殑淇℃伅
/// </summary>
public override void Refresh()
@@ -109,11 +170,12 @@
IsSelected = isSelected;
}
- /// <summary>
- /// 鏂囧瓧澶у皬,榛樿12
- /// </summary>
- /// <value>The size of the text.</value>
- public float TextSize
+ float mTextSize = Application.FontSize;
+ /// <summary>
+ /// 鏂囧瓧澶у皬,榛樿12
+ /// </summary>
+ /// <value>The size of the text.</value>
+ public float TextSize
{
get
{
@@ -121,6 +183,7 @@
}
set
{
+ mTextSize = value;
iosButton.TitleLabel.Font = UIFont.FromName(FontName, value);
}
}
@@ -154,11 +217,11 @@
}
uint selecteTextColor = 0xFFFFFFFF;
-/// <summary>
-/// 鏂囧瓧棰滆壊
-/// </summary>
-/// <value>The color of the text.</value>
-public uint SelectedTextColor
+ /// <summary>
+ /// 鏂囧瓧棰滆壊
+ /// </summary>
+ /// <value>The color of the text.</value>
+ public uint SelectedTextColor
{
get
{
@@ -395,7 +458,7 @@
set;
}
- class MyButton : UIKit.UIButton
+ public class MyButton : UIKit.UIButton
{
[Weak] View view;
public MyButton(View view)
--
Gitblit v1.8.0