制作的iOS栏按钮项为iOS 6的看起来像iOS的7 UIBarButtonSystemItemAdd
问题描述:
我想用一个UILabel设置为文本@“+”看起来像UIBarButtonSystemItemAdd iOS中7。到目前为止,我有...制作的iOS栏按钮项为iOS 6的看起来像iOS的7 UIBarButtonSystemItemAdd
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
[lbl setText:@"+"];
[lbl setFont:[UIFont systemFontOfSize:36]];
[lbl setTextAlignment:NSTextAlignmentCenter];
addButton = [[UIBarButtonItem alloc] initWithCustomView:lbl];
...但问题是+不在导航栏上垂直居中。我试着改变标签的框架,但+总是出现在相同的地方,稍微太低。
任何想法?
答
问题是+是不上下方向中央的导航栏上
考虑使用图像而不是字符串。通过图像,您可以更好地控制按钮的绘制方式。
+0
我不能这样做,因为它是我希望用户能够更改颜色的框架的一部分。它很容易改变字体颜色,但对于图像来说不那么容易 –
比较屏幕截图非常有帮助 – JustAnotherCoder