0
我想通過繼承來輕鬆定製Mvvmcross對話框實現中的某些元素。更改MvvmCross對話框元素的佈局/框架
顏色和字體設置得很好,但如果我嘗試設置文本標籤框(在本示例中爲100 X ......),我無法使其保持粘貼狀態。
任何人都可以指出我在哪裏出錯的方向嗎?在幾個不同的地方嘗試過。
public class MyBooleanElement : BooleanElement {
public MyBooleanElement (string caption) : base(caption, false)
{
}
protected override UISwitch CreateSwitch()
{
UISwitch s = base.CreateSwitch();
s.BackgroundColor = UIColor.Clear;
s.Opaque = false;
s.Layer.Opacity = 0.25f;
return s;
}
protected override UITableViewCell GetCellImpl(UITableView tv)
{
var cell = base.GetCellImpl(tv);
if (cell.BackgroundColor != UIColor.Clear) {
cell.BackgroundColor = UIColor.Clear;
cell.TextLabel.Font = Theme.GetContentFont();
cell.TextLabel.TextColor = UIColor.White;
cell.TextLabel.Frame = new RectangleF(100, 0, 320, 20); // this is not holding, resets to 15
cell.ContentView.Frame = new RectangleF(50, cell.ContentView.Frame.Top, cell.ContentView.Frame.Width, cell.ContentView.Frame.Height); // try this also?
}
return cell;
}
protected override void UpdateCaptionDisplay(UITableViewCell cell)
{
base.UpdateCaptionDisplay(cell);
if (cell != null) {
cell.TextLabel.Frame = new RectangleF(100, 0, 320, 20); // this is not holding, resets to 15
cell.TextLabel.BackgroundColor = UIColor.Blue; // Yet this works? some constraints somewhere cannot see in source!
}
}
}
謝謝安德烈,我對源代碼有很好的看法,並且必須按照您的說法設置下一步的調試,因爲您可能會猜到希望以前有人碰到過。您是否使用PC上的Visual Studio進行調試或XS? – WickedW 2014-10-27 18:42:04