2015-02-02 2 views
1

사용자가 테이블보기를 스크롤 할 때 탐색 막대의 알파 값을 변경할 수 있는지 물어보고 싶습니다.스크롤 할 때 탐색 막대의 알파 편집 tableview

나는 알고리즘을 가지고 있지만, 실시간으로 변경 사항을 얻으려면 도움이 필요합니다.

/* This is the offset at the bottom of the scroll view. */ 
CGFloat totalScroll = scrollView.contentSize.height - scrollView.bounds.size.height; 

/* This is the current offset. */ 
CGFloat offset = - scrollView.contentOffset.y; 

/* This is the percentage of the current offset/bottom offset. */ 
CGFloat percentage = offset/totalScroll; 

/* When percentage = 0, the alpha should be 1 so we should flip the percentage. */ 
scrollView.alpha = (1.f - percentage); 

답변

2

은 너무 늦었 아마도,하지만 나중에 참조 할 수 있도록, 당신은 같은 것을 할 수있는 : 당신이있는 ScrollView 나있는 tableView의 contentOffset의 값이이 위임에

func scrollViewDidScroll(scrollView: UIScrollView) { 
    self.navigationController!.navigationBar.alpha = 1 - (self.tableView.contentOffset.y/(self.tableView.contentSize.height - self.tableView.frame.size.height)); 
} 

을, 당신은 관찰 할 수 당신이 원하는 행동을하기 위해이 속성의 가치.

희망이 있습니다.

관련 문제