模擬qq空間吞滞,滑動放大或縮小圖片的動態(tài)效果
先創(chuàng)建一個navigationController對象辱揭,默認(rèn)是隱藏的狀態(tài)
設(shè)置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;
}
}
具體代碼請點擊下載