Please help me to make the UICollectionview header transparent while we scroll the collection view up. I have used UICollectionReusableView and set it background as clear color, but no use. WHILE MOVING UP THE HEADER ( SHOWN IN BLACK COLOR) SHOULD BECOME TRANSPARENT.... THAT IS THE ORANGE BACKGROUND SHOULD BE SLIGHTLY VISIBLE....
Asked
Active
Viewed 454 times
0
-
Could you, please, be more specific? In what moment do you set background of UICollectionReusableView? How do you access it? The best would be, if you can post some code – Sergii Martynenko Jr Jul 28 '15 at 09:56
-
And what do you mean, "UICollectionview header". It's not quite clear, 'cause UICollectionView doesn't have `header` property (like UITableView has) – Sergii Martynenko Jr Jul 28 '15 at 10:14
1 Answers
0
Not enough info, but I'll try to answer
First, you should keep pointer to your header view constantly
@property UICollectionReusableView *collectionHeaderView;
Create it once in viewDidLoad
and than use it as a header view (whatever that means) in your collection view.
Next, to change collor on dragging up you'll need delegate method. UICollectionViewDelegate conforms to UIScrollViewDelegate, so you can use its method
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView.superview];
if(translation.y > 0)
{
//dragging down
collectionHeaderView.backgroundColor = <#Whatever you need#>;
} else
{
// dragging up
collectionHeaderView.backgroundColor = [UIColor clearColor];
}
}
Special thanks to @mvielbut for answer
Update
According to comments to mvielbut's answer, this method is not always reliable, so you can use another approach (you'll need to check offset.y
instead).

Community
- 1
- 1

Sergii Martynenko Jr
- 1,407
- 1
- 9
- 18
-
-
Like I said, not enough info. Your photo doesn't provide any new info – Sergii Martynenko Jr Jul 28 '15 at 10:20
-
-
Read my comments. And check my answer. I believe, it should help. P. S. I can see clearly, so, please, turn caps lock off – Sergii Martynenko Jr Jul 28 '15 at 10:23
-