模拟qq空间,滑动放大或缩小图片的动态效果
先创建一个navigationController对象,默认是隐藏的状态
设置navigationController的显示与隐藏的逻辑
- (void)setNavigaionBarVisibility:(GKFadeNavigationControllerNavigationBarVisibility)navigaionBarVisibility
{
BOOLchanged =NO;
if(!_navigaionBarVisibility!= navigaionBarVisibility) {
changed =YES;
}
_navigaionBarVisibility= navigaionBarVisibility;
// Play the change
if(changed) {
GKFadeNavigationController*navigationController = (GKFadeNavigationController*)self.navigationController;
[navigationControllersetNeedsNavigationBarVisibilityUpdateAnimated:YES];
}
}
滑动tableview之后navigationController显示隐藏的处理(scrollView的代理方法)
- (void)scrollViewDidScroll:(UIScrollView*)scrollView
{
CGFloatscrollOffsetY =kGKHeaderHeight-scrollView.contentOffset.y;
// Stretch the header view if neccessary
if(scrollOffsetY >kGKHeaderHeight) {
self.imageTopConstraint.constant=kGKHeaderHeight-scrollOffsetY;
}else{
self.imageTopConstraint.constant= (kGKHeaderHeight-scrollOffsetY)/2.f;
self.imageBottomConstraint.constant= -(kGKHeaderHeight-scrollOffsetY)/2.f;
}
// Show or hide the navigaiton bar
if(scrollOffsetY-kGKNavbarHeight
self.navigaionBarVisibility=GKFadeNavigationControllerNavigationBarVisibilityVisible;
}else{
self.navigaionBarVisibility=GKFadeNavigationControllerNavigationBarVisibilityHidden;
}
}
具体代码请点击下载