gpt4 book ai didi

ios - 我想复制这个导航栏,这个是安卓版的,我该怎么做?

转载 作者:行者123 更新时间:2023-11-28 08:04:09 24 4
gpt4 key购买 nike

Navigation bar in android which is to be replicated in iOS

图片是我想使用 swift 3 在 ios 中复制的 android 导航栏。我已经为此工作了几天,但我无法正确完成任何帮助。

let height: CGFloat = 128  //whatever height you want
let bounds = self.navigationController!.navigationBar.bounds
self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)

我这样做是为了使导航栏的高度正确,但我似乎无法使栏按钮的位置正确。

最佳答案

像这样添加barbutton-

let myBackButton = UIButton(type: .custom)
myBackButton.addTarget(self, action: #selector(backAction), for: UIControlEvents.touchUpInside)
myBackButton.setTitle("YOUR TITLE", for: UIControlState.normal)
myBackButton.setTitleColor(UIColor.blue, for: UIControlState.normal)
myBackButton.sizeToFit()
myBackButton.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
let myCustomBackButtonItem:UIBarButtonItem = UIBarButtonItem(customView: myBackButton)
self.navigationItem.leftBarButtonItem = myCustomBackButtonItem

关于ios - 我想复制这个导航栏,这个是安卓版的,我该怎么做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45673809/

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