layout - 带有透明/模糊导航栏的 iOS 7 View Controller 布局问题

标签 layout ios7 rubymotion

我在使用 iOS 7 中的 View Controller 时遇到问题。我正在尝试找出最佳方法来调整导航栏和状态栏下的 View 布局,同时保持导航栏的透明度/模糊。例如,如果我有一个 View Controller :

def viewDidLoad
  @scroll                      = UIScrollView.alloc.initWithFrame(new_frame)
  @scroll.bounces              = true
  @scroll.delegate             = self
  @scroll.alwaysBounceVertical = true
  @scroll.scrollsToTop         = true
  @scroll.contentSize          = CGSizeMake(UIScreen.mainScreen.bounds.size.width, scroll_frame.size.height)


  self.view.addSubview(@scroll)
end

我的内容显示在导航栏下方,我得到了 iOS 7 转换指南。要纠正这个问题,如果我在 viewDidLoad 中添加以下内容:

self.edgesForExtendedLayout = UIRectEdgeNone

布局已调整,但导航栏不再透明或模糊,因为 View 不在其后延伸。

如果我不调整 scrollView insets 而不是为布局设置边缘:

self.automaticallyAdjustsScrollViewInsets = false

然后将我的滚动框更改为:

def viewDidLoad
  nav_bar_height = self.navigationController.navigationBar.frame.size.height
  status_height  = UIApplication.sharedApplication.statusBarFrame.size.height

  height = nav_bar_height + status_height

  scroll_frame = self.view.bounds

  new_frame = CGRect.new([0, height], [scroll_frame.size.width, scroll_frame.size.height])

  @scroll                      = UIScrollView.alloc.initWithFrame(new_frame)
  @scroll.bounces              = true
  @scroll.delegate             = self
  @scroll.alwaysBounceVertical = true
  @scroll.scrollsToTop         = true
  @scroll.contentSize          = CGSizeMake(UIScreen.mainScreen.bounds.size.width, scroll_frame.size.height)


  self.view.addSubview(@scroll)

end

我不再获得导航栏的透明/模糊效果。只有当我将卷轴的框架 - 在 x 原点 - 调整为新高度时,这似乎才会发生。所以我想知道为什么会这样,以及如何在不丢失模糊/透明度的情况下最好地调整滚动条。

最佳答案

也许你可以试试inset

[scroll setContentInset:UIEdgeInsetsMake(nav_bar_height + status_height, 0.0, 0.0, 0.0)];
[scroll setScrollIndicatorInsets:UIEdgeInsetsMake(nav_bar_height + status_height,0.0,0.0,0.0)];

希望对你有帮助

关于layout - 带有透明/模糊导航栏的 iOS 7 View Controller 布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18883733/

相关文章:

ios - 设置 contentInset 或automaticallyAdjustsScrollViewInsets 后我必须做什么才能实际应用它?

ruby - 新的 RubyMotion 和 Joybox 的问题

ios - iOS 导航栏中标题的分页效果

java - recyclerview inside nestedscrollview addOnScrollListener (endless scrolllistener)

layout - Extjs 如何为 vbox 面板设置 100% 高度

ios - iOS 7:从json响应中选择特定对象

cocoapods - RubyMotion 和 CocoaPods 问题

android - 如何将 Android fragment 添加到 Activity 中?

android - Android 平板电脑和智能手机中最受欢迎的屏幕分辨率/比率

iOS保持线程在后台运行