状态栏重叠iOS7中的内容 [英] statusbar overlapping content in iOS7

查看:104
本文介绍了状态栏重叠iOS7中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用iOS7,我放在状态栏下方的工具栏已与状态栏合并

With iOS7 the toolbar I placed right under the statusbar has merged with the statusbar

但当我将工具栏向下移动20px时,它看起来像

but when I move the toolbar 20px down, then it looks like

我如何获得第一张图片的效果(状态栏与工具栏颜色相同),但不能将其与状态栏合并。或者这应该在iOS7中以不同方式完成?

How can I have the effect of the first picture (statusbar with same color as toolbar) but not merging it with the statusbar. Or should this be done differently in iOS7?

推荐答案

将自己设置为工具栏代理。然后在视图控制器中,实现 UIBarPositioningDelegate 。按如下方式实施:

Set yourself as the toolbar delegate. Then in your view controller, implement UIBarPositioningDelegate. Implement it as follows:

Objective-C

- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar {
    return UIBarPositionTopAttached;
}

Swift

func positionForBar(bar: UIBarPositioning) -> UIBarPosition {
  return .TopAttached
}

还要确保移动工具栏20点(正如您已经做过的那样),或者在状态栏下方,以便发生此效果。

Also make sure you move your toolbar 20 points down (as you already did), or right underneath the status bar, for this effect to take place.

这篇关于状态栏重叠iOS7中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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