From 1a13c963a5fb8cad92bf03667e411f46d6a6a843 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 17 十二月 2020 15:10:33 +0800
Subject: [PATCH] Revert "Merge branch 'tzy' into NewFilePath"
---
HDL_ON/UI/UI0-Public/Widget/TextButton.cs | 93 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 92 insertions(+), 1 deletions(-)
diff --git a/HDL_ON/UI/UI0-Public/Widget/TextButton.cs b/HDL_ON/UI/UI0-Public/Widget/TextButton.cs
index c0a5b02..4148731 100644
--- a/HDL_ON/UI/UI0-Public/Widget/TextButton.cs
+++ b/HDL_ON/UI/UI0-Public/Widget/TextButton.cs
@@ -1,7 +1,9 @@
锘縰sing System;
using Shared;
+
#if __IOS__
using UIKit;
+using Foundation;
#endif
namespace HDL_ON.UI
@@ -9,6 +11,7 @@
/// <summary>
/// TextButton
/// 瑙e喅iOS 鏂囨湰鍒拌竟妗嗘湁杈硅窛闂
+ ///
/// </summary>
public class TextButton : Button
{
@@ -20,5 +23,93 @@
#endif
}
- }
+
+ int _lineSpacing;
+ /// <summary>
+ /// 璁剧疆琛岄棿璺�
+ /// </summary>
+ public int LineSpacing
+ {
+ set
+ {
+ _lineSpacing = value;
+ SetButtonLineSpacing(_lineSpacing);
+ }
+ }
+
+
+#if __IOS__
+ /// <summary>
+ /// 鎸夐挳璁剧疆琛岃窛鏂规硶
+ /// </summary>
+ /// <param name="spacing"></param>
+ void SetButtonLineSpacing(int spacing)
+ {
+ UIStringAttributes stringAttributes = new UIStringAttributes
+ {
+ Font = (this.uiView as MyButton).TitleLabel.Font,
+ ForegroundColor = UIColor.Black,
+ ParagraphStyle = new NSMutableParagraphStyle() { LineSpacing = spacing }
+ };
+ var AttributedText = new NSMutableAttributedString(Text);
+ AttributedText.AddAttributes(stringAttributes, new NSRange(0, Text.Length));
+ (this.uiView as MyButton).TitleLabel.AttributedText = AttributedText;
+ }
+
+ /// <summary>
+ /// 鏄剧ず褰撳墠鏂囧瓧闇�瑕佸嚑琛�
+ /// </summary>
+ /// <returns></returns>
+ int GetNeedLinesWithWidth()
+ {
+ return 0;
+ }
+ /**
+
+
+// @param width 缁欏畾涓�涓搴�
+// @return 杩斿洖琛屾暟
+// */
+//- (NSInteger) needLinesWithWidth:(CGFloat) width
+// {
+// //鍒涘缓涓�涓猯abe
+// UILabel * label = [[UILabel alloc]
+// init];
+// //font鍜屽綋鍓峫abel淇濇寔涓�鑷�
+// label.font = self.font;
+// NSString* text = self.text;
+// NSInteger sum = 0;
+// //鎬昏鏁板彈鎹㈣绗﹀奖鍝嶏紝鎵�浠ヨ繖閲岃绠楁�昏鏁帮紝闇�瑕佺敤鎹㈣绗﹀垎闅旇繖娈垫枃瀛楋紝鐒跺悗璁$畻姣忔鏂囧瓧鐨勮鏁帮紝鐩稿姞鍗虫槸鎬昏鏁般��
+// NSArray* splitText = [text componentsSeparatedByString: @"\n"];
+// for (NSString* sText in splitText)
+// {
+// label.text = sText;
+// //鑾峰彇杩欐鏂囧瓧涓�琛岄渶瑕佺殑size
+// CGSize textSize = [label systemLayoutSizeFittingSize: CGSizeZero];
+// //size.width/鎵�闇�瑕佺殑width 鍚戜笂鍙栨暣灏辨槸杩欐鏂囧瓧鍗犵殑琛屾暟
+// NSInteger lines = ceilf(textSize.width / width);
+// //褰撴槸0鐨勬椂鍊欙紝璇存槑杩欐槸鎹㈣锛岄渶瑕佹寜涓�琛岀畻銆�
+// lines = lines == 0 ? 1 : lines;
+// sum += lines;
+// }
+// return sum;
+// }
+
+ //#elif __Android__
+#else
+
+ /// <summary>
+ /// 鎸夐挳璁剧疆琛岃窛鏂规硶
+ /// </summary>
+ /// <param name="spacing"></param>
+ void SetButtonLineSpacing(int spacing)
+ {
+ (this.AndroidView as Android.Widget.Button).SetLineSpacing(spacing, 1);
+ }
+
+#endif
+ }
+
+
+
}
--
Gitblit v1.8.0