2012-05-22 25 views
6

¿Cómo puedo conseguir que UIBezierpath de UIImage como esto ..UIBezierpath de enmascarar un UIImage

enter image description here

no quiero trayectoria plaza llena, sólo quiero que la ruta como se muestra en el borde rojo de UIImage ..

me había pasado por Link 1 y Link 2 pero no pueden conseguido el éxito ..

que había hecho siguiente código para obtener la ruta enmascarar ..

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

Básicamente quiero conseguir UIBezierpath que sigue la forma de alfabetos como la A, B .. etc

Por favor, dime esto es posible o no para obtener este tipo de ruta ??

Gracias de antemano ..

+0

¿Has resuelto el problema? Parece que todavía no hay respuesta para tu pregunta sobre stackoverflow ...: o ( – Dirk

Respuesta

-5

probar este código:

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

También verifica este tutorial ... creo que resuelve tu problema ... http://blog.devedup.com/index.php/2010/03/03/iphone-animate-an-object-along-a-path/ – jamil

+0

Esta respuesta no está relacionada con la pregunta. Preguntaron cómo obtener un UIBezierPath que podría dibujar esa forma, no una animación sobre un camino . –

0

Para otros usuarios en busca de respuestas, un enfoque alternativo se pueden encontrar here (El uso de SVG como un archivo de imagen de origen y convertir PocketSVG a las rutas)