From c44b10e4447e84dbdfa9105edf460ef364a8f2b3 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 30 十一月 2020 19:53:35 +0800
Subject: [PATCH] Merge branch 'master' into WJC

---
 HDL_ON/UI/UI0-Public/Widget/TextButton.cs |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 115 insertions(+), 0 deletions(-)

diff --git a/HDL_ON/UI/UI0-Public/Widget/TextButton.cs b/HDL_ON/UI/UI0-Public/Widget/TextButton.cs
new file mode 100644
index 0000000..4148731
--- /dev/null
+++ b/HDL_ON/UI/UI0-Public/Widget/TextButton.cs
@@ -0,0 +1,115 @@
+锘縰sing System;
+using Shared;
+
+#if __IOS__
+using UIKit;
+using Foundation;
+#endif
+
+namespace HDL_ON.UI
+{
+    /// <summary>
+    /// TextButton
+    /// 瑙e喅iOS 鏂囨湰鍒拌竟妗嗘湁杈硅窛闂
+    /// 
+    /// </summary>
+    public class TextButton : Button
+    {
+        public TextButton()
+        {
+#if __IOS__
+            //閲嶅啓淇敼鏂囨湰鍒拌竟妗嗙殑鍐呰竟璺濅负0
+            (this.uiView as MyButton).ContentEdgeInsets = new UIEdgeInsets(0, 0, 0, 0);
+#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