2012-05-22 15 views
6

Come posso ottenere UIBezierpath da UIImage come questo ..Get UIBezierpath da mascherare un UIImage

enter image description here

Non voglio percorso completo piazza, Voglio solo che il percorso come indicato nella bordo rosso da UIImage ..

ero andato attraverso Link 1 e Link 2 ma non posso avuto successo ..

avevo fatto seguente codice per ottenere il percorso mascherare ..

CAShapeLayer *maskLayer = [CAShapeLayer layer]; 
maskLayer.frame = imgView.frame; 
UIBezierPath *roundedPath = [UIBezierPath bezierPathWithRoundedRect:maskLayer.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(50.f, 50.f)]; 

Fondamentalmente voglio ottenere UIBezierpath che segue la forma di alfabeti come A, B ecc ..

La prego di dirmi è questo possibile o meno di ottenere questo tipo di percorso ??

Grazie in anticipo ..

+0

Hai risolto il problema? Sembra che non ci sia ancora alcuna risposta alla tua domanda su StackOverflow ...: o ( – Dirk

risposta

-5

provare questo codice:

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation 
animationWithKeyPath:@"position"]; 
pathAnimation.calculationMode = kCAAnimationPaced; 
pathAnimation.fillMode = kCAFillModeForwards; 
pathAnimation.removedOnCompletion = NO; 
pathAnimation.duration = 15.0; 
pathAnimation.repeatCount = 1; 
CGMutablePathRef curvedPath = CGPathCreateMutable(); 
CGPathMoveToPoint(curvedPath, NULL, x+15, y); 
CGPathAddQuadCurveToPoint(curvedPath, NULL, 20, 10, 100, 330); 
pathAnimation.path = curvedPath; 
CGPathRelease(curvedPath); 
Yourimage.center=CGPointMake(x, y); 
[Yourimage.layer addAnimation:pathAnimation forKey:@"moveTheSquare"]; 
+0

Controlla anche questo tutorial .. penso che risolva il tuo problema .. http://blog.devedup.com/index.php/2010/03/03/iphone-animate-an-object-along-a-path/ – jamil

+0

Questa risposta non è correlata alla domanda posta, ma ha chiesto come ottenere un UIBezierPath che potrebbe disegnare quella forma, non un'animazione su un percorso . –

0

Per gli altri utenti in cerca di risposte, un approccio alternativo può essere trovato here (Usando SVG come un file di immagine di origine e PocketSVG per convertire ai percorsi)