淘宝商品详情页导航栏的Item的切换


图片描述

如图, 导航栏默认是透明的, 此时BarButtonItem的图标是带灰色背景的,
当滑动后,导航条完全显示出来时 BarButtonItem的灰色背景会隐藏 ,
请问这个是换图片还是修改alpha , 望大神指点 !!

ios objective-c

炮姐D凝视 9 years, 3 months ago

 self.scrollView.delegate = self;


- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
   CGPoint offset = scrollView.contentOffset;
   if (offset.y < 100.f) {
      self.navigationController.navigationBar.alpha = 1.f - offset.y / 100.f;
      self.navigationItem.leftBarButtonItem = ...;
      self.navigationItem.rightBarButtonItem = ...;
   }
   else {
      self.navigationController.navigationBar.alpha = MIN(1.f, (offset.y - 100.f) / 100.f);
      self.navigationItem.leftBarButtonItem = ...;
      self.navigationItem.rightBarButtonItem = ...;
  }
}

Himeno酱 answered 9 years, 3 months ago

应该是组合模式 先透明度 最后换图片

黯ye守望着 answered 9 years, 3 months ago

就是一个判断滚动条位置,然后元素背景过度!去研究css3过度属性

苍天啊大地啊 answered 9 years, 3 months ago

Your Answer