iOS支付宝首页效果-仿

新做的项目,UI指着支付宝首页,咱们就做这个效果!因为之前也被指着说做Instagram的相册选择效果,就满口答应了。本着无百度不扣钉的思想,也发现有人写了这个。哈哈,可以复制啦。然而,看了代码之后,还是决定自己写了。

盗图1(侵删).jpeg
盗图2(侵删).jpeg

此实现仅使用一个UITableview。顶部View是加在tableview上的。向上滑动的时候,不用任何处理,顶部View就会上滑。向下滑动的时候,实现ScollView的代理即可。额,太简单了~~,没写就完了。只能上代码凑字数了。

- (void)viewDidLoad {
   [super viewDidLoad];
   _contentInsetTop = 100;

  _topView = [[UIView alloc] initWithFrame:CGRectMake(0, -_contentInsetTop, SDScreenWidth, _contentInsetTop)];
  _topView.backgroundColor = [UIColor redColor];

  UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
  tableView.dataSource = self;
  tableView.delegate   = self;
  tableView.contentInset = UIEdgeInsetsMake(_contentInsetTop, 0, 0, 0);
  tableView.scrollIndicatorInsets = tableView.contentInset;
  [self.view addSubview:tableView];
  [tableView addSubview:_topView];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat offsetY = scrollView.contentOffset.y;
    if (offsetY < -_contentInsetTop) {
        _topView.frame = CGRectMake(0, offsetY, SDScreenWidth, _contentInsetTop);
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容