在集合视图单元格中,我有一个文本视图,它是在
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath我正在为文本排除创建一个bezier路径,如下所示
CGRect exclusionRect=CGRectMake(0,0, cell.coverImage.frame.size.width, cell.coverImage.frame.size.height);
UIBezierPath *exclusionPath=[UIBezierPath bezierPathWithRect:exclusionRect];
cell.issueInfo.textContainer.exclusionPaths=@[exclusionPath];但是,当文本视图滚动时,bezier路径保持在文本视图中的固定状态,因此我的文本将被图像屏蔽。
如何使bezier路径在文本视图滚动时不移动?
发布于 2014-06-11 10:43:44
通过让我的自定义UICollectionViewCell子类采用UITextViewDelegate协议并将单元格设置为
-(void)awakeFromNib由于UITextViewDelegate协议继承了UIScrollView协议,所以我实现了
-(void)scrollViewDidScroll:(UIScrollView *)scrollView在此方法中,我计算并应用bezierpath,如下所示
self.exclusionPath=[UIBezierPath bezierPathWithRect:[self.textView convertRect:self.imageView.bounds fromView:self.imageView]];
self.textView.textContainer.exclusionPaths=@[self.exclusionPath];希望这能帮到别人!
https://stackoverflow.com/questions/23936822
复制相似问题