| | |
| | | using Foundation; |
| | | using Shared.IO; |
| | | using System; |
| | | using CoreGraphics; |
| | | |
| | | namespace Shared |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 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); |
| | | } |
| | | |
| | |
| | | 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 { } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /// <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() |
| | |
| | | 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 |
| | | { |
| | |
| | | } |
| | | set |
| | | { |
| | | mTextSize = value; |
| | | iosButton.TitleLabel.Font = UIFont.FromName(FontName, value); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | 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 |
| | | { |
| | |
| | | set; |
| | | } |
| | | |
| | | class MyButton : UIKit.UIButton |
| | | public class MyButton : UIKit.UIButton |
| | | { |
| | | [Weak] View view; |
| | | public MyButton(View view) |