Objective c 为什么我的品牌不符合我的形象?

Objective c 为什么我的品牌不符合我的形象?,objective-c,uiimageview,uiimage,uigesturerecognizer,Objective C,Uiimageview,Uiimage,Uigesturerecognizer,将图像作为子视图添加到另一个UIImageView时,我在新图像上添加了一个标记,该标记应在编辑时跟随(移动、放大/缩小、旋转) 我不能让品牌保持连接到新图像的框架,虽然在添加图像时,它最初是连接的,但一旦移动,品牌就会离开图像框。 这是我的密码: **viewDidLoad:** if (!_marque) { _marque = [[CAShapeLayer layer] retain]; _marque.fillColor = [[UIColor clearColor

将图像作为子视图添加到另一个
UIImageView
时,我在新图像上添加了一个标记,该标记应在编辑时跟随(移动、放大/缩小、旋转)

我不能让品牌保持连接到新图像的框架,虽然在添加图像时,它最初是连接的,但一旦移动,品牌就会离开图像框。

这是我的密码:

 **viewDidLoad:**
 if (!_marque)
 {
    _marque = [[CAShapeLayer layer] retain];
    _marque.fillColor = [[UIColor clearColor] CGColor];
    _marque.strokeColor = [[UIColor cyanColor] CGColor];
    _marque.lineWidth = 1.0f;
    _marque.lineJoin = kCALineJoinRound;
    _marque.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:10],[NSNumber numberWithInt:5], nil];
    _marque.bounds = CGRectMake(_stampedImageView.frame.origin.x, _stampedImageView.frame.origin.y, 0, 0);
    _marque.position = CGPointMake(_stampedImageView.frame.origin.x + self.view.frame.origin.x, _stampedImageView.frame.origin.y + self.view.frame.origin.y);
 }
 [[_stampedImageView layer] addSublayer:_marque];

 **marque Method:**
 if (![_marque actionForKey:@"linePhase"])
 {
    CABasicAnimation *dashAnimation;
    dashAnimation = [CABasicAnimation animationWithKeyPath:@"lineDashPhase"];
    [dashAnimation setFromValue:[NSNumber numberWithFloat:0.0f]];
    [dashAnimation setToValue:[NSNumber numberWithFloat:15.0f]];
    [dashAnimation setDuration:0.5f];
    [dashAnimation setRepeatCount:HUGE_VALF];
    [_marque addAnimation:dashAnimation forKey:@"linePhase"];
 }

_marque.bounds = CGRectMake(_stampedImageView.frame.origin.x, _stampedImageView.frame.origin.y, 0, 0);
_marque.position = CGPointMake(_stampedImageView.frame.origin.x, _stampedImageView.frame.origin.y);

CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, frame);
[_marque setPath:path];
CGPathRelease(path);

_marque.hidden = NO;

 **panGestureRecognizer:**
 CGPoint translatedPoint = [(UIPanGestureRecognizer*)sender translationInView:self.view];

if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan)
{
    _firstX = [_stampedImageView center].x;
    _firstY = [_stampedImageView center].y;
}

translatedPoint = CGPointMake(_firstX+translatedPoint.x, _firstY+translatedPoint.y);

[_stampedImageView setCenter:translatedPoint];
[self showOverlayWithFrame:_stampedImageView.frame];
有人能帮我看看我遗漏了什么吗


谢谢

我想您可能在这一行有错误:

CGPathAddRect(path, NULL, frame);

在我能看到的任何地方,你都没有定义框架。也许_stampedImageView.frame?

frame来自方法:-(void)showOverlayWithFrame:(CGRect)frame