Подтвердить что ты не робот

Настройка линии в соответствии с нашей головой в режиме просмотра изображений

Я разрабатываю одно приложение так же, как HairTryOn, все сделано. но проблема отображается на следующем изображении. Я хочу установить прическу в соответствии с лицом клиента, используя синюю линию в соответствии с отображением на изображении. я использовал следующий код

    testVw = [[UIView alloc]initWithFrame:CGRectMake(100,100, 100, 100)];
    testVw.backgroundColor = [UIColor clearColor];
    [self.view addSubview:testVw];    


    resizeVw = [[UIImageView    alloc]initWithFrame:CGRectMake(testVw.frame.size.width-25, testVw.frame.size.height-25, 25, 25)];
    resizeVw.backgroundColor = [UIColor clearColor];
    resizeVw.userInteractionEnabled = YES;
    resizeVw.image = [UIImage imageNamed:@"button_02.png" ];

    [testVw addSubview:resizeVw];

    UIPanGestureRecognizer* panResizeGesture = [[UIPanGestureRecognizer alloc] 
    initWithTarget:self action:@selector(resizeTranslate:)];

    [testVw addGestureRecognizer:panResizeGesture];

Метод resizeTranslate::

-(void)resizeTranslate:(UIPanGestureRecognizer *)recognizer
{
        if ([recognizer state]== UIGestureRecognizerStateBegan) 
        {
            prevPoint = [recognizer locationInView:testVw.superview];
            [testVw setNeedsDisplay];
        }
        else if ([recognizer state] == UIGestureRecognizerStateChanged)
        {
            if (testVw.bounds.size.width < 20)
            {

                testVw.bounds = CGRectMake(testVw.bounds.origin.x, testVw.bounds.origin.y, 20,testVw.bounds.size.height);
                imgvw.frame = CGRectMake(12, 12, testVw.bounds.size.width-24, testVw.bounds.size.height-27);
                resizeVw.frame =CGRectMake(testVw.bounds.size.width-25, testVw.bounds.size.height-25, 25, 25);
                rotateVw.frame = CGRectMake(0, testVw.bounds.size.height-25, 25, 25);
                closeVw.frame = CGRectMake(0, 0, 25, 25);            
            }

            if(testVw.bounds.size.height < 20)
            {
                testVw.bounds = CGRectMake(testVw.bounds.origin.x, testVw.bounds.origin.y, testVw.bounds.size.width, 20);
                imgvw.frame = CGRectMake(12, 12, testVw.bounds.size.width-24, testVw.bounds.size.height-27);
                resizeVw.frame =CGRectMake(testVw.bounds.size.width-25, testVw.bounds.size.height-25, 25, 25);
                rotateVw.frame = CGRectMake(0, testVw.bounds.size.height-25, 25, 25);
                closeVw.frame = CGRectMake(0, 0, 25, 25);
            }

            CGPoint point = [recognizer locationInView:testVw.superview];
            float wChange = 0.0, hChange = 0.0;

            wChange = (point.x - prevPoint.x); //Slow down increment
            hChange = (point.y - prevPoint.y); //Slow down increment 


            testVw.bounds = CGRectMake(testVw.bounds.origin.x, testVw.bounds.origin.y, testVw.bounds.size.width + (wChange), testVw.bounds.size.height + (hChange));
            imgvw.frame = CGRectMake(12, 12, testVw.bounds.size.width-24, testVw.bounds.size.height-27);

            resizeVw.frame =CGRectMake(testVw.bounds.size.width-25, testVw.bounds.size.height-25, 25, 25);
            rotateVw.frame = CGRectMake(0, testVw.bounds.size.height-25, 25, 25);
            closeVw.frame = CGRectMake(0, 0, 25, 25);

            prevPoint = [recognizer locationInView:testVw.superview];

            [testVw setNeedsDisplay];
    }
    else if ([recognizer state] == UIGestureRecognizerStateEnded)
    {
        prevPoint = [recognizer locationInView:testVw.superview];
        [testVw setNeedsDisplay];
    }
}

Этот код Изменение размера полного вида. но я хочу изменить размер только той части, которая перемещается пальцем. enter image description here

4b9b3361

Ответ 1

Я не вижу, как ваши примитивы построены. Но вам нужно будет разбить ваш набор очков в соответствии с сенсорными зонами и затем масштабировать по мере необходимости. Если вы преобразуете свои строки в кривые Безье, то манипуляция кривой будет проще, так как вам не нужно будет делать ужасную корректировку фигуры с небольшими изменениями.