gpt4 book ai didi

xcode - 设置 leftBarButtonItem 垂直位置

转载 作者:行者123 更新时间:2023-11-28 06:59:15 27 4
gpt4 key购买 nike

我试图给 leftBarButtonItem 一个上边距,但它不起作用。我可以将它向右移动,但不能向下移动。

self.navigationItem.leftBarButtonItem?.setTitlePositionAdjustment(UIOffsetMake(10, 20), forBarMetrics: UIBarMetrics.Default)

水平参数 10 起作用,它将标题向右移动。但是垂直参数 20 无论我将其更改为什么数字都没有任何作用。

完整代码:

let attributes = [NSFontAttributeName: UIFont.ioniconOfSize(24)] as Dictionary!
let newBackButton = UIBarButtonItem(title: String.ioniconWithName(Ionicon.ChevronLeft), style: UIBarButtonItemStyle.Plain, target: self, action: "back:")
self.navigationItem.leftBarButtonItem = newBackButton;
self.navigationItem.leftBarButtonItem?.setTitleTextAttributes(attributes, forState: .Normal)
self.navigationItem.leftBarButtonItem?.setBackgroundVerticalPositionAdjustment(5, forBarMetrics: UIBarMetrics.Default)

最佳答案

尝试:

self.navigationItem.leftBarButtonItem?.setBackgroundVerticalPositionAdjustment(5, forBarMetrics: UIBarMetrics.Default)

关于xcode - 设置 leftBarButtonItem 垂直位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32476877/

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