我希望创建一个自定义的UIView,其中包含一个UIImageView和一个UILabel,指向UICollectionView滚动指示器,并随其一起滚动。
但是指示器视图并不完全跟随指示器!!
我正在使用这段代码:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//get refrence of vertical indicator
UIImageView *verticalIndicator = ((UIImageView *)[scrollView.subviews objectAtIndex:(scrollView.subviews.count-1)]);
// get the relative position of the indicator in the main window
CGPoint p = [verticalIndicator convertPoint:verticalIndicator.bounds.origin toView:[[UIApplication sharedApplication] keyWindow]];
// set the custom view new position
CGRect indicatorFrame = self.indicatorView.frame;
indicatorFrame.origin.y = p.y;
self.indicatorView.frame = indicatorFrame;
}
但是指示器视图并不完全跟随指示器!!