淘宝商品详情页导航栏的Item的切换
如图, 导航栏默认是透明的, 此时BarButtonItem的图标是带灰色背景的,
当滑动后,导航条完全显示出来时 BarButtonItem的灰色背景会隐藏 ,
请问这个是换图片还是修改alpha , 望大神指点 !!
炮姐D凝视
9 years, 3 months ago
Answers
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