gpt4 book ai didi

swift - 在 Swift 中实现自定义导航栏

转载 作者:行者123 更新时间:2023-11-28 08:10:06 26 4
gpt4 key购买 nike

我想要一个自定义的 Navigation Controller,我做了很多搜索,我阅读了很多关于 Stack 的问题等等。但我仍然不知道该怎么做。

我想做那个导航栏:

enter image description here

添加图标真的很困难,如果我想让它们可以移动就更难了。效果和 Instagram 是一样的(当我点击按钮时,图标在旋转)。

阶段 1:

enter image description here

阶段 2:

enter image description here

最佳答案

只需要在导航栏标题中添加一个图片按钮即可

let button = UIButton.init(type: .custom)
button.setImage(UIImage.init(named: "YourImage"), for: UIControlState.normal)
button.frame = CGRect.init(x: 0, y: 0, width: 30, height: 30)
button.addTarget(self, action: #selector(self.onButtonClicked), for: .touchUpInside)
self.navigationItem.titleView = button

关于swift - 在 Swift 中实现自定义导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43974562/

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