2013-03-14 10 views
10

Sto sviluppando un'applicazione uguale a HairTryOn tutte le operazioni sono state eseguite. ma il problema è visualizzato nell'immagine seguente. Voglio impostare l'acconciatura come per il viso del cliente usando la linea blu come da visualizzazione nell'immagine. ho usato il seguente codiceRegolazione della linea per adattarsi alla nostra testa in imageview

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]; 

Il resizeTranslate: metodo:

-(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]; 
    } 
} 

Questo codice ridimensionamento pieno. ma voglio ridimensionare solo la parte che viene mossa dal dito. enter image description here

+0

puoi darmi una risposta? –

+1

Cosa, esattamente, stai chiedendo? Vedo un sacco di codice, ma nessuna domanda chiara! – Adam

+0

ok, non sappiamo come creare questi effetti. Si prega di installare HairTryOn app per iPhone. e vedere l'effetto acconciatura. anche [vedi] (http://stackoverflow.com/questions/15701125/split-the-image-into-a-mesh-of-small-quadrangles-in-opengles) –

risposta

2

Non vedo come sono costruite le tue primitive. Ma dovrai partizionare il tuo set di punti in base alle zone di contatto e ridimensionarlo in base alle esigenze. Se converti le tue linee in curve di Bezier, la manipolazione della curva sarà più semplice, poiché non avrai bisogno di fare troppe modifiche alla forma con piccole modifiche.

+0

qualsiasi codice di esempio? –

Problemi correlati