2013-03-14 2 views
10

저는 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

+0

대답 해 주실 수 있습니까? –

+1

정확히 무엇을 요구하고 있습니까? 많은 코드가 있지만 명확한 질문은 없습니다! – Adam

+0

좋습니다. 우리는이 효과를 만드는 방법을 모릅니다. HairTryOn iPhone 앱을 설치하십시오. 헤어 스타일 효과를 볼 수 있습니다. 또한 [참조] (참조 http://stackoverflow.com/questions/15701125/split-the-image-into-a-mesh-of-small-quadrangles-in-opengles) –

답변

2

원시가 어떻게 구성되는지는 알 수 없습니다. 그러나 터치 존에 따라 포인트 세트를 분할하고 필요에 따라 스케일을 조정해야합니다. 선을 베 지어 곡선으로 변환하면 커브를 조작하는 것이 쉬울 것입니다. 작은 수정을 가해도 모양에 끔찍한 조정을 할 필요가 없기 때문입니다.

+0

어떤 샘플 코드? –

관련 문제