[下載地址]https://git.oschina.net/mrj_mrj/pagesFilp.git
實現(xiàn)原理:
用一個UIScrollow 作為最底下的試圖,上面加載兩個可以滾動的試圖,比如UITableView,UIScrollow,UIWebView,這里用的是UITableView和UIWebView.
效果圖:
關(guān)鍵代碼部分:
- 1:初始化布局
<p>UIScrollView</p><pre><code>
-
(UIScrollView *)baseScrollow
{if (_baseScrollow == nil)
{
_baseScrollow = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, _screenWide, _screenHeight)];
_baseScrollow.contentSize = CGSizeMake(_screenWide, _screenHeight * 2);
//設置分頁效果
_baseScrollow.pagingEnabled = YES;
//禁用滾動
_baseScrollow.scrollEnabled = NO;
}return _baseScrollow;
}
</code></pre>
<p>UITableView</p><pre><code>
-
(UITableView *)topTableView
{if (!_topTableView) {
_topTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, _screenWide, _screenHeight) style:UITableViewStylePlain];
[_topTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
_topTableView.delegate = self;
_topTableView.dataSource = self;
}return _topTableView;
}
</code></pre>
<p>UIWebView</p><pre><code>
-
(UIWebView *)webView
{if (!_webView) {
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, _screenHeight, _screenWide, _screenHeight)];
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]]];
}return _webView;
}
</code></pre>
<p>滑動效果</p><pre><code>
self.topTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
[UIView animateWithDuration:1 animations:^{
self.baseScrollow.contentOffset = CGPointMake(0, _screenHeight);
} completion:^(BOOL finished) {
[self.topTableView.mj_footer endRefreshing];
}];
}];
self.webView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
[UIView animateWithDuration:1 animations:^{
self.baseScrollow.contentOffset = CGPointMake(0, 0);
} completion:^(BOOL finished) {
[self.webView.scrollView.mj_header endRefreshing];
}];
}];
}
</code></pre>