@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
CALayer *layer = [CALayer layer];
layer.delegate = self;
layer.bounds = CGRectMake(0, 0, 100, 100);
layer.position = CGPointMake(100, 100);
layer.anchorPoint = CGPointZero;
layer.backgroundColor = [UIColor blackColor].CGColor;
[layer setNeedsDisplay];
[self.view.layer addSublayer:layer];
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGContextSetRGBFillColor(ctx, 1.0, 0, 0, 1.0);
CGContextAddRect(ctx, CGRectMake(0, 0, 20, 20));
CGContextFillPath(ctx);
}
CABasicAnimation *basicAnimation = [CABasicAnimation animation];
basicAnimation.keyPath = @"position";
basicAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, 0)];
basicAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(200, 200)];
basicAnimation.duration = 1.0;
basicAnimation.removedOnCompletion = NO;//动画执行完以后不要删除动画
basicAnimation.fillMode = kCAFillModeForwards;//保持最新的状态
[self.layer addAnimation:basicAnimation forKey:nil];
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);