public NumberInputView() { BackgroundColor = UIColor.Black.ColorWithAlpha(.5f); Add(numberPanel = new StackPanel { Columns = 3, Padding = 5, }); Enumerable.Range(1, 9).ForEach(x => numberPanel.Add(createButton(x.ToString()))); numberPanel.Add(createButton(".")); numberPanel.Add(createButton("0")); numberPanel.Add(createButton("del")); done = new TintedButton { Layer = { CornerRadius = 5 }, BackgroundColor = UIColor.White, Frame = new RectangleF(0, 0, 44, 44), Title = "Done", Font = UIFont.SystemFontOfSize(30), SelectedTintColor = UIColor.Black, TintColor = TintColor, }; done.TouchUpInside += (object sender, EventArgs e) => { EndEditing(); }; Add(done); }
UIButton createButton(string text) { const float width = 80; var btn = new TintedButton { Layer = { CornerRadius = 5 }, BackgroundColor = UIColor.White, Frame = new RectangleF(0, 0, width, width), Title = text, Font = UIFont.SystemFontOfSize(30), SelectedTintColor = TintColor, TintColor = UIColor.Black, }; btn.TouchUpInside += (object sender, EventArgs e) => ButtonPressed(text); return(btn); }
public NumberInputView() { BackgroundColor = UIColor.Black.ColorWithAlpha(.5f); Add(numberPanel = new StackPanel{ Columns = 3, Padding = 5, }); Enumerable.Range(1,9).ForEach(x=> numberPanel.Add(createButton(x.ToString()))); numberPanel.Add(createButton(".")); numberPanel.Add(createButton("0")); numberPanel.Add(createButton("del")); done = new TintedButton { Layer = { CornerRadius = 5 }, BackgroundColor = UIColor.White, Frame = new RectangleF(0,0,44,44), Title = "Done", Font = UIFont.SystemFontOfSize(30), SelectedTintColor = UIColor.Black, TintColor = TintColor, }; done.TouchUpInside += (object sender, EventArgs e) =>{ EndEditing(); }; Add(done); }
UIButton createButton(string text) { const float width = 80; var btn = new TintedButton { Layer = { CornerRadius = 5 }, BackgroundColor = UIColor.White, Frame = new RectangleF(0,0,width,width), Title = text, Font = UIFont.SystemFontOfSize(30), SelectedTintColor = TintColor, TintColor = UIColor.Black, }; btn.TouchUpInside += (object sender, EventArgs e) => ButtonPressed (text); return btn; }