UINavigationController隐藏与显示,滑动图片放大缩小效果

模拟qq空间,滑动放大或缩小图片的动态效果


UINavigationController隐藏与显示,滑动图片放大缩小效果_第1张图片
图1

先创建一个navigationController对象,默认是隐藏的状态

图2

设置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;

}

}

具体代码请点击下载

你可能感兴趣的:(UINavigationController隐藏与显示,滑动图片放大缩小效果)