【问题标题】:i want to replicate this navigation bar, this one is an android version how do i do it?我想复制这个导航栏,这个是安卓版本,我该怎么做?
【发布时间】:2017-08-14 11:45:49
【问题描述】:

Navigation bar in android which is to be replicated in iOS

图片是一个 android 导航栏,我想使用 swift 3 在 ios 中复制它。我已经为此工作了几天,但我无法正确解决任何问题。

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)

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

【问题讨论】:

标签: ios swift uinavigationitem


【解决方案1】:

像这样添加 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多