搜索并突出显示在UIView中呈现的PDF中的文本 [英] Search and highlight text in PDF rendered in UIView

查看:60
本文介绍了搜索并突出显示在UIView中呈现的PDF中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 brow-leaves-67b10ed 在UIView中呈现PDF 。

I have used brow-leaves-67b10ed to render PDFs in UIView.

现在我的必要性是搜索和突出显示文本。

Now my necessity is to search and highlight texts.

我已经设法在UIView上获得文本的确切位置。现在UIView由许多层组成,以支持叶子动画,页面也缓存在图像中,然后在这些图层上绘制。这里出现了实际问题。我想在所有图层顶部的搜索位置绘制一个填充矩形,这是我无法做到的。如果我为UIView调用setsneedRect,则调用drawRect但不绘制矩形,而CALayer的setsneedsRect不会调用drawLayer:inContext ..任何人都可以帮我如何继续?请尽快回复。
提前致谢。

I have managed to get the exact position of text on UIView. Now UIView consists of many layers to support leaves animation and also pages are cached in images and then drawn on these layers. Here the actual problem occurs. I want to draw a filled rectangle at searched position on top of all layers which I am unable to do. If I call setsneedRect for UIView, drawRect is called but rectangle is not drawn, and setsneedsRect for CALayer doesnt call drawLayer: inContext.. Can any one help me how to proceed?? Please reply asap. Thanks in advance.

编辑

现在代码正在调用drawLayer:inContext:
我在下面添加了行..

Now the code is calling drawLayer: inContext: I added below line..

[super setNeedsDisplay];
[searchLayer setNeedsDisplay];

但似乎仍然没有发生..

But still nothing seems to happen..

因为我为CALayer(searchLayer)调用了setNeedsDisplay,所以上下文将是CALayer ..
这是我的代码,我在显示高亮显示:

Since I called setNeedsDisplay for CALayer (searchLayer) the context will be of CALayer.. Here is my code where I am displaying the highlights:

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{
for (Selection *s in self.selections)
{
    CGContextSaveGState(ctx);

    CGContextConcatCTM(ctx, [s transform]);
    CGContextSetFillColorWithColor(ctx, [[UIColor yellowColor] CGColor]);
    CGContextSetBlendMode(ctx, kCGBlendModeMultiply);
    CGContextFillRect(ctx, [s frame]);
    CGContextRestoreGState(ctx);
}

}

任何人都可以提供帮助吗?

Can any one help out there?

推荐答案

这是在叶子视图中在不适当的图层中填充rect的问题。我尝试添加具有适当层位置的那些并完成。

That was an issue with filling rect in inappropriate layer in leaves view. I tried adding those with proper layer position and that is done.

但我建议,如果你想突出显示搜索到的文字,不要使用UIView ..不要至少离开视图

But I recommend, not to use UIView if you want to highlight searched text.. Not atleast leaves view

这篇关于搜索并突出显示在UIView中呈现的PDF中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆