在自定义 ScrollView 中绘图
我正在尝试使用多点触控在图像顶部绘制滚动视图。这些圆圈实际上是绘制的,但位于图像下方。在我的代码中,我当前创建了一个自定义 ScrollView:
@interface AppScrollView : UIScrollView {
//objects to draw circles
NSMutableDictionary *circlesInProcess;
NSMutableArray *completeCircles;
}
@end
在我的 AppScrollView.m 中,我重写触摸命令来存储触摸并添加一个
(void)drawRect:(CGRect) rect
方法来在滚动视图中绘制圆圈。我还包括
[self setNeedsDisplay]
显示圆圈。在我的应用程序控制器中,我声明了新的自定义滚动视图对象:
IBOutlet AppScrollView *scrollView;
稍后,我使用以下方法将图像添加到滚动视图:
[scrollView addSubview:myImage];
图像是可见的,但是当我尝试在其顶部绘制圆圈时,它们会绘制在图像下方。如果您有任何建议请告诉我?
I'm trying to draw in a scrollview on top of an image using multi-touch. The circles are actually drawn, but under the image. In my code I currently create a custom ScrollView:
@interface AppScrollView : UIScrollView {
//objects to draw circles
NSMutableDictionary *circlesInProcess;
NSMutableArray *completeCircles;
}
@end
In my AppScrollView.m I override touches commands to store touches and add a
(void)drawRect:(CGRect) rect
method to draw the circles in the scrollview. I also include
[self setNeedsDisplay]
to display the circles. In my app controller, I declare the new custom scrollView object:
IBOutlet AppScrollView *scrollView;
Later I add an image to the scrollView using:
[scrollView addSubview:myImage];
The image is visible, but when I try to draw circles on top of it, they are drawn under the image. Let me know if you have any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
建议:将图像绘制到滚动视图上(而不是将图像视图添加为子视图),然后在其顶部绘制圆圈。
Suggestion: draw the image onto your scrollview (instead of adding the image view as a subview) and then draw the circles on top of that.
在您的代码中检查您在哪里添加自定义滚动视图。是在添加imageView之后添加还是之前添加。
你的scrollView应该在imageView之上。
In your code check where did you add you custom scrollview. Is it added after imageView is added or before.
You scrollView should be on top of imageView.