pei*_*rix 4 xamarin.ios monotouch.dialog
有没有办法在Monotouch Dialog类实例化时设置字体?
[Section("This is the header")]
Run Code Online (Sandbox Code Playgroud)
这将使用带阴影的默认蓝色文本进行渲染,但我找不到该字体的设置位置.有没有办法覆盖它使用的字体和颜色?
我为那些希望在整个解决方案中替换所有节头的人找到了解决方案.在MonoTouch.Dialog,有一个名为class的类DialogViewController,在使用反射API创建视图时使用.在这里,有一个叫做的方法GetViewForHeader().section.HeaderView您可以创建自定义标签并将其发回,而不是仅发回正常标签.
public override UIView GetViewForHeader (UITableView tableView, int sectionIdx)
{
var section = Root.Sections [sectionIdx];
if (!string.IsNullOrEmpty(section.Caption))
{
var label = new UILabel();
label.BackgroundColor = UIColor.FromRGB(89, 41, 17);
label.TextColor = UIColor.FromRGB(255, 206, 52);
label.ShadowColor = UIColor.Black;
label.ShadowOffset = new SizeF(0, 1f);
label.Font = UIFont.FromName("TitlingGothicFB Cond", 20);
label.Text = section.Caption;
return label;
}
return section.HeaderView;
}
public override float GetHeightForHeader (UITableView tableView, int sectionIdx)
{
if (!string.IsNullOrEmpty(section.Caption))
return 40f;
return -1;
}
Run Code Online (Sandbox Code Playgroud)
请记住手动或通过从标签获取高度来设置高度.您也可以创建自定义UIView,但标签对我来说已经足够了.
| 归档时间: |
|
| 查看次数: |
4210 次 |
| 最近记录: |