锚点UIView [英] Anchor a UIView

查看:153
本文介绍了锚点UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在UINavigationController里面有一个UITableViewController。

I have a UITableViewController inside of a UINavigationController.

我想有一个UIView出现在表视图的顶部,但不容易滚动的表视图。

I want to have a UIView appear over the top of the table view but not susceptible to the scrolling of the table view.

如果滚动表视图,UIView应保持在相对于屏幕的相同位置,而不是相对于表视图。

I.e. if the table view is scrolled, the UIView should remain in the same position relative to the screen, rather than relative to the table view. It should appear anchored in a certain position.

这是最好的方法是什么?

What is the best way to achieve this?

要澄清,视图应该在表视图顶部透明地浮动。

To clarify, the view should float transparently over the top of the table view.

非常感谢!

推荐答案

我也想在我的tableView有一个浮动的UIView。

所以,在我的RootViewController(这是一个UITableViewController),这对我工作

I also wanted to have a floating UIView over my tableView.
So, within my RootViewController (which is a UITableViewController), this worked for me

- (void)viewDidLoad {
    /* mylabel is a UILabel set in this class */
    [self.mylabel setUserInteractionEnabled:NO];

    /* navigationController comes from higher up in the navigation chain */
    [self.navigationController.view addSubview:self.mylabel]; 
 }

这篇关于锚点UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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