gpt4 book ai didi

iphone - 如何调整 UIToolbar 实例包含的 UIBarButtonItem 的框架或垂直对齐方式?

转载 作者:行者123 更新时间:2023-12-03 18:18:42 29 4
gpt4 key购买 nike

UIBarButtonItems 的水平定位没有问题,我可以简单地用固定/灵活的空间项填充空间。但是,我似乎无法垂直调整工具栏项目。 UIToolbar 没有对齐属性,UIBarButtonItem 无法设置其框架。

我需要这样做,因为我们混合使用了使用 initWithImage 创建的自定义图标和使用 initWithBarButtonSystemItem 创建的标准图标。自定义图标未正确居中(相对于正确居中的系统图标,它们向上偏移),因此工具栏看起来很尴尬。

最佳答案

是的,imageInsets 对我来说效果很好!

 float topInset = 4.0f;
myUIBarButton.imageInsets = UIEdgeInsetsMake(topInset, 0.0f, -topInset, 0.0f);

将图像向下移动 4 个像素。

避免这种情况:

 float topInset = 4.0f;
myUIBarButton.imageInsets = UIEdgeInsetsMake(topInset, 0.0f, 0.0f, 0.0f);

将图像向下移动 4 个像素(但重新调整图像高度,使其看起来被压缩)。

关于iphone - 如何调整 UIToolbar 实例包含的 UIBarButtonItem 的框架或垂直对齐方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2786017/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com