我使用 uibutton 在标题中显示一些文本,有时文本很长,我设置
text.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap;
当有 2 行或更多行时,背景没有足够的高度
这是我的按钮代码:
text = new UIButton ();
text.Layer.CornerRadius = 5;
text.Font = UIFont.FromName ("DIN Condensed", text.Font.PointSize);
text.SetTitle (Original._hint, UIControlState.Normal);
text.SizeToFit ();
text.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap;
var rec = new UILongPressGestureRecognizer (() => {
text.Frame = new CGRect ((UIApplication.SharedApplication.KeyWindow.Frame.Width / 2.0f) - (250 / 2.0f),
this.Superview.Superview.Superview.Frame.Height / 2.0f,250, text.Frame.Height);
Animate (0.6f, () => {
this.Superview.Superview.Superview.AddSubview (text);
}, () => {
text.Layer.ZPosition = int.MaxValue;
});
viewToremove=text;
});
text.SetTitleColor (UIColor.White, UIControlState.Normal);
text.BackgroundColor = UIColor.Black;
TargetView.AddGestureRecognizer (rec);