iOS支付寶首頁效果-仿

新做的項(xiàng)目,UI指著支付寶首頁,咱們就做這個(gè)效果!因?yàn)橹耙脖恢钢f做Instagram的相冊(cè)選擇效果,就滿口答應(yīng)了。本著無百度不扣釘?shù)乃枷耄舶l(fā)現(xiàn)有人寫了這個(gè)。哈哈,可以復(fù)制啦。然而,看了代碼之后,還是決定自己寫了。

盜圖1(侵刪).jpeg
盜圖2(侵刪).jpeg

此實(shí)現(xiàn)僅使用一個(gè)UITableview。頂部View是加在tableview上的。向上滑動(dòng)的時(shí)候,不用任何處理,頂部View就會(huì)上滑。向下滑動(dòng)的時(shí)候,實(shí)現(xiàn)ScollView的代理即可。額,太簡單了~~,沒寫就完了。只能上代碼湊字?jǐn)?shù)了。

- (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);
    }
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容