I try to add floating section header view in my collectionView. But after adding in it, I noticed that the fps goes down when I try to scroll it. I check UI Hierarchy, I found that the header view overlapped.
The overlapped header viewClick here to see the pic...
I used a third party lib to add the floating effect of header view, the page of this lib is https://github.com/hytzxd/XDSectionHeaderCollectionView. What I wrote in my .m file is:
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
NSString *time = [self.dates objectAtIndex:indexPath.section];
// UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
// UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
UIView *effectView = [[UIView alloc] init];
effectView.frame = headerView.bounds;
UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, effectView.bounds.size.width, effectView.bounds.size.height/2)];
timeLabel.text = time;
[effectView addSubview:timeLabel];
UILabel *locationLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, effectView.bounds.size.height/2, effectView.bounds.size.width, effectView.bounds.size.height/2)];
locationLabel.text = @"获取中...";
locationLabel.font = [UIFont systemFontOfSize:10];
[effectView addSubview:locationLabel];
timeLabel.backgroundColor = [UIColor clearColor];
timeLabel.layer.masksToBounds = YES;
locationLabel.backgroundColor = [UIColor clearColor];
locationLabel.layer.masksToBounds = YES;
[headerView addSubview:effectView];
retu headerView;
}
retu nil;
}
I tried to use blur effect view for the first time, I couldn't find any problem, so I changed to a normal UIView.
