我的 View 中有一个工具栏。它包含一个带有图标的条形按钮项目,实际上它不是图标(它是自定义字体)。我用它来统一同一客户的其他 Web 应用程序的图标。
无论如何,我怎样才能稍微增加上边距……也许给定的示例显示了一个过滤器图标,我可以轻松地将其替换为真实图像图标(不是字体)。但是其他一些图标,是不可能的。
编辑 1:
我正在使用 C# (Xamarin)。就算有object-c的代码。我同意。
var att = new UITextAttributes ();
att.Font = FontHelper.GetIconFont (32.0f);
this.btnFilter.SetTitleTextAttributes (att, UIControlState.Normal);
自定义图标字体方法:
public static UIFont GetIconFont(float size)
{
var nfloatSize = nfloat.Parse (((float)size).ToString ());
return UIFont.FromName(_fontIcons, nfloatSize);
}
最佳答案
尝试这样的事情,
float offset = 3.0f;
UIBarButtonItem * barItem = [[UIBarButtonItem alloc] initWithTitle:@"title"
style:UIBarButtonItemStyleDone
target:nil action:@selector(someMessage)];
[barItem setBackgroundVerticalPositionAdjustment:offset forBarMetrics:UIBarMetricsDefault];
关于ios - 如何更改 UIBarButtonItem 的上边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32327190/