Mat*_*ton 0 xamarin.ios monotouch.dialog
我试图在MonoTouch对话框中的Section元素标题中自定义文本的位置.我读到你应该如何创建自己的UILabel来创建样式文本,然后将其分配给Section对象的HeaderView.那部分效果很好.
我现在面临的问题是:如何获得与默认的无样式Section元素中使用的偏移量相似的文本偏移量(请参阅附加图像中的比较).无论我做什么,我似乎无法找到让"Styled Section"文本从屏幕左边移开的方法.我尝试更改RectangleF声明中指定的x坐标,但是在呈现视图时,我指定的任何内容都会被忽略.
以下是截图的支持代码:
Root = new RootElement ("Login2Screen");
var labelHeader = new UILabel();
labelHeader = new UILabel(new RectangleF(0, 0, 320, 48));
labelHeader.Text = "Styled
labelHeader.TextColor = UIColor.Blue;
labelHeader.BackgroundColor = UIColor.Clear;
var styledSection = new Section(labelHeader);
styledSection.Add(new EntryElement("Username", string.Empty, string.Empty));
styledSection.Add(new EntryElement("Password", string.Empty, string.Empty));
Root.Add(styledSection);
var defaultStyleSection = new Section("Default Section");
Root.Add (defaultStyleSection);
Run Code Online (Sandbox Code Playgroud)

小智 5
将labelHeader添加到UIView中,然后将UILabel的x坐标设置为10.
var viewLabelHeader = new UIView(new RectangleF(0, 0, 320, 48));
var labelHeader = new UILabel(new RectangleF(10, 0, 320, 48));
labelHeader.Text = "Styled section";
labelHeader.TextColor = UIColor.Blue;
labelHeader.BackgroundColor = UIColor.Clear;
viewLabelHeader.AddSubview (labelHeader);
var styledSection = new Section(viewLabelHeader);
Run Code Online (Sandbox Code Playgroud)
结果:

| 归档时间: |
|
| 查看次数: |
862 次 |
| 最近记录: |