का उपयोग करके आकार के कोरग्राफिक्स को एनिमेट करने के लिए मैं UIView उपclass में UIBeizerPath (मेरे उदाहरण में एक त्रिकोण) के चित्र को एनिमेट करने का प्रयास कर रहा हूं। हालांकि, संपूर्ण सबव्यू आकार के बजाय एनिमेटिंग है।कोरग्राफिक्स एनीमेशन
क्या मुझे एनीमेशन के साथ कुछ याद आ रही है?
- (void)drawRect:(CGRect)rect {
CAShapeLayer *drawLayer = [CAShapeLayer layer];
drawLayer.frame = CGRectMake(0, 0, 100, 100);
drawLayer.strokeColor = [UIColor greenColor].CGColor;
drawLayer.lineWidth = 4.0;
[self.layer addSublayer:drawLayer];
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0,0)];
[path addLineToPoint:CGPointMake(50,100)];
[path addLineToPoint:CGPointMake(100,0)];
[path closePath];
CGPoint center = [self convertPoint:self.center fromView:nil];
[path applyTransform:CGAffineTransformMakeTranslation(center.x, center.y)];
[[UIColor redColor] set];
[path fill];
[[UIColor blueColor] setStroke];
path.lineWidth = 3.0f;
[path stroke];
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.duration = 4.0f;
pathAnimation.path = path.CGPath;
pathAnimation.calculationMode = kCAAnimationLinear;
[drawLayer addAnimation:pathAnimation forKey:@"position"];
}
के बारे में बताएं कि वास्तव में क्या मतलब है "एक UIBezierPath के ड्राइंग चेतन"। क्या आप चाहते हैं कि यह व्यक्तिगत सेगमेंट खींचें, एक के बाद एक, या क्या? –
@ कर्ट हां मैं प्रत्येक बिंदु के चित्र को एनिमेट करना चाहता हूं ताकि त्रिभुज एनिमेटेड –