From 79fe8dab1bcb8e8d92d9058ca2540cd4e8f9ecf9 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期五, 27 十一月 2020 14:05:32 +0800
Subject: [PATCH] 20201127 合并嘉乐代码

---
 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