如何设置我的iOS故事板像Instagram流一样反弹?

Mic*_*ley 5 storyboard bounce ios instagram

我正在构建一个带有社交内容流的应用程序,并试图了解instagram如何在应用程序中进行流式传输.所以基本上是一个顶部标题,滚动屏幕但在内容和内容之间反弹.我可以让顶部标题滚动离开屏幕,我可以让视图不反弹但我想使用Pull来刷新,最终会在"faux"导航栏上方UIView.我知道一个普通的Navbar会产生这个但是这个滚动的是一个不同的故事.

目前,我有一个UITableview具有UIView上述UITableViewCell和除弹跳发生上述的一切都很正常UIView.我想我需要得到UIView上面的UITableView但是在UITableViewController中,故事板不允许我放置UIView上面的UITableView.

有任何想法吗???

谢谢

Mic*_*ley 5

好吧,我终于把这一切都搞定了,所以我想我会把答案发给大家.

基本上我设置了一个标准的导航栏,然后scrollViewDidScroll我得到了滚动的偏移量并根据它改变了帧.这看起来很完美,请参阅下面的scrollViewDidScroll方法.

- (void)scrollViewDidScroll:(UIScrollView *)sender {

    //Initializing the views and the new frame sizes.
    UINavigationBar *navbar = self.navigationController.navigationBar;
    UIView *tableView = self.view;

    CGRect navBarFrame = self.navigationController.navigationBar.frame;
    CGRect tableFrame = self.view.frame;

    //changing the origin.y based on the current scroll view.
    //Adding +20 for the Status Bar since the offset is tied into that.
    navBarFrame.origin.y = MIN(0, (sender.contentOffset.y * -1)) +20;
    navbar.frame = navBarFrame;

    tableFrame.origin.y = MIN(0,MAX(-44,(sender.contentOffset.y * -1)));
    tableView.frame = tableFrame;

}
Run Code Online (Sandbox Code Playgroud)

此外,您还需要使TableView 44px更高以补偿滚动,否则您的框架将不够大.我只是在viewWillAppear中做了这个,并使框架更大.