开发者

Display a tableView over another view

I would like to achieve a similar effect:

http://imageshack.us/m/695/3715/img0419s.png

My initial idea was to create something like presentend in this schema http://imageshack.us/m/9/9227/img0413.png. Ie a ViewController with 2 subviews: a classical one with some information, and a tableView 开发者_Python百科below which should scroll over the previous view.

But I realized that dividing the main view this way couldn't allow my tableview to scroll over the first view.

So I'm asking how this effect is possible. Maybe by setting a transparent header ?

Thanks for your help


Following the teriiehina's advise, here is how I dit it :

In my UITableViewController, I set a 50px contentInset and a transparent color to my tableView.

self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.contentInset = UIEdgeInsetsMake(50,0,0,0);

I added an additional view on the top of the view (same size than the contentInset)

TTView *test = [[TTView alloc] init];
test.frame = CGRectMake(0, 0, 320, 50);
test.backgroundColor = [UIColor grayColor];
[self.view addSubview:test];

Finally, in order to let my tableview scroll over the additional view, I brought it in the front

[self.view bringSubviewToFront:self.tableView];

Now I just have to set a custom color for my cells.


A dirty trick here:

  1. Add the UIView that contains the name first
  2. Add a UIScrollView with clipBounds = NO. That view will contain the message.

That should work for you


I think you can achieve this effect using the contentInset property of the UITableView (which is a UIScrollView subclass) and presenting the tableView at first with a programmatic scroll.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜