0

我正在尝试在 UIImageView 中绘制一些东西。我可以使用以下代码在 UIView 中毫无问题地绘制:

@implementation DrawView
{
    UIBezierPath *path; 
}

- (id)initWithCoder:(NSCoder *)aDecoder 
{
    if (self = [super initWithCoder:aDecoder])
    {
        [self setMultipleTouchEnabled:NO]; 
        [self setBackgroundColor:[UIColor whiteColor]];
        path = [UIBezierPath bezierPath];
        [path setLineWidth:2.0]; 
    }
    return self;
}

- (void)drawRect:(CGRect)rect 
{
    [[UIColor blackColor] setStroke];
    [path stroke];
}


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint p = [touch locationInView:self];
    [path moveToPoint:p];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint p = [touch locationInView:self];
    [path addLineToPoint:p]; // (4)
    [self setNeedsDisplay];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self touchesMoved:touches withEvent:event];
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self touchesEnded:touches withEvent:event];
}

这会跳过 imageview .. 我需要的是相反的。我想画一个 uiimageview 并跳过 uiview .. 我该怎么做?提前致谢..

在此处输入图像描述

4

1 回答 1

0

绘图表面必须是此视图集层次结构中的父级。这样您就可以在父视图上绘制,而图像位于下方。

-Main View
--Drawing View
---UIImageView
于 2013-11-22T23:58:12.200 回答