在大标题导航栏中添加按钮 [英] Add a button to large title navigation bar

查看:131
本文介绍了在大标题导航栏中添加按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在大型标题导航栏中添加一个按钮,例如App Store的帐户按钮.

I'd like to add a button to a large title navigation bar like App Store's account button.

所需流量:

  1. 仅当启用large titles时按钮才可见
  2. 当用户在视图中滚动时,允许从大标题过渡到普通标题.
  1. Button is visible only when large titles is enabled
  2. Allow transition from large titles to normal when user scrolls inside the view.

注意:我使用情节提要.

推荐答案

如果要在导航到该视图控制器的子级时隐藏/显示图像:

And in case you want to hide/show the image when you navigate to children of this view controller:

/**
 Show or hide the image from NavBar while going to next screen or back to initial screen

 - parameter show: show or hide the image from NavBar
 */
private func showImage(_ show: Bool) {
  UIView.animate(withDuration: 0.4) {
    self.settingsImageView.alpha = show ? 1.0 : 0.0
  }
}

override func viewWillDisappear(_ animated: Bool) {
  super.viewWillDisappear(animated)
  showImage(false)
}

override func viewWillAppear(_ animated: Bool) {
  super.viewDidAppear(animated)
  showImage(true)
}

如果这对您有所帮助,您可以查看实际文章并给作者鼓掌一声或两声

If this helped you, you can check out the actual article and give the author a clap or two

这篇关于在大标题导航栏中添加按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆