适用于iOS 7的TableView中的ViewController和导航栏模糊效果 [英] iOS 7 TableView in a ViewController and NavigationBar blurred effect

查看:202
本文介绍了适用于iOS 7的TableView中的ViewController和导航栏模糊效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在故事板使用TableViewController建设的TableView我的应用程序。当你这样做,你有一个非常酷的效果,当你向下滚动列表:移动导航栏后面的细胞得到模糊

I started building a TableView in my app by using a TableViewController in a storyboard. When you do this, you have a very cool effect when you scroll down your list : the cells moving behind the nav bar get blurred.

一段时间后,我不得不从这个TableViewController移动到的ViewController用的TableView内(我不得不在表格的下方添加其他的观点)。

Some time later, I had to move from this TableViewController to a ViewController with a TableView inside (I had to add other views at the bottom of the table).

为了避免具有由导航栏(即在它)隐藏在第一单元,I加约束到顶部和底部版式参考,并视图的左右边缘。

In order to avoid having the first cells hidden by the navigation bar (being over it), I added constraints to the Top and Bottom Layout Guides, and to the left and right edges of the view.

这工作得很好,但我失去了凉爽的迷离滚动效果:在细胞似乎才去导航栏后面将消失

This works fine, but I lost the cool blurred scrolling effect : the cells seem to be disappearing before going behind the navigation bar.

我见过的人没有使用限制,并把幻数在Interface Builder中的解决方法。我不能做到这一点,首先是因为我不喜欢,其次是因为我必须iOS 6的兼容。

I've seen workarounds with people not using constraints and putting magic numbers in interface builder. I cannot do this, first because I dislike it, and second because I have to be iOS 6 compatible.

我错过了什么是能够从模糊的导航栏效果再次受益?

What did I miss to be able to benefit again from the blurred navigation bar effect ?

推荐答案

您必须手动调整表视图的 contentInset ,并确保表视图框原点0,0。
这样,表视图将导航栏下方,但会有内容和滚动视图边缘(内容被下移)。

You have to manually adjust the contentInset of the table view and make sure the table view frame origin is 0, 0. In this way the table view will be below the navigation bar, but there will be some margin between the content and the scroll view edges (the content gets shifted down).

我建议你使用视图控制器的 topLayoutGuide 属性来设置正确的 contentInsets ,而不是硬编码64(状态栏+导航栏)。
还有 bottomLayoutGuide ,你应该在以下情况下使用 UITapBar 秒。

I advise you to use the topLayoutGuide property of the view controller to set the right contentInsets, instead of hard coding 64 (status bar + navigation bar). There's also bottomLayoutGuide, which you should use in case of UITapBars.

下面是一些示例code( viewDidLoad中应该是罚款):

Here is some sample code (viewDidLoad should be fine):

// Set edge insets
CGFloat topLayoutGuide = self.topLayoutGuide.length;
tableView.contentInset = UIEdgeInsetsMake(topLayoutGuide, 0, 0, 0);

顺便说一句,的UIViewController 的这个特性可以帮助你(你应该不需要更改其默认值,但我不知道你的视图层次是什么)

By the way, this properties of UIViewController might help you (you should not need to change their default values, but I don't know what your view hierarchy is):


  • automaticallyAdjustsScrollViewInsets

  • edgesForExtendedLayout

  • extendedLayoutIncludesOpaqueBars

  • automaticallyAdjustsScrollViewInsets
  • edgesForExtendedLayout
  • extendedLayoutIncludesOpaqueBars

这篇关于适用于iOS 7的TableView中的ViewController和导航栏模糊效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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