简体   繁体   English

根据xamarin.ios中的内容调整UILabel高度

[英]Adjust UILabel height by content in xamarin.ios

i have 3 types of string labels, "loading...", "loading, please wait" and "it's taking more than we expected, sorry...". 我有3种类型的字符串标签,“加载......”,“加载,请稍候”和“它比我们预期的要多,抱歉......”。 I want to adjust the height of the IULabel and center in the frame. 我想调整IULabel的高度并在框架中居中。 I'm using this: 我正在使用这个:

labelTitle = new UILabel (new CGRect (
                frame.Width / 4,
                frame.Height / 2 + Dimensions.margin_small,
                frame.Width/2,
                40
            ));
labelTitle.StyleTitle ();
labelTitle.TextAlignment = UITextAlignment.Center;
labelTitle.LineBreakMode = UILineBreakMode.WordWrap;
labelTitle.Lines = 0;

But don't know how to resize the height 但不知道如何调整高度

try this. 尝试这个。

labelTitle = new UILabel ();
labelTitle.StyleTitle ();
labelTitle.TextAlignment = UITextAlignment.Center;
labelTitle.LineBreakMode = UILineBreakMode.WordWrap;
labelTitle.Lines = 0;

And now give the label center point. 现在给标签中心点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM