小编Mar*_*ith的帖子

使用Monotouch时如何将CGColor转换为NSObject?

我试图在CAShapeLayer上设置CGColor fillColor属性的动画.我可以使用Objective-C使用以下语法使其正常工作:

- (void)viewDidLoad {
    [super viewDidLoad];

    // Create the path
    thisPath = CGPathCreateMutable();
    CGPathMoveToPoint(thisPath, NULL, 100.0f, 50.0f);
    CGPathAddLineToPoint(thisPath, NULL, 10.0f, 140.0f);
    CGPathAddLineToPoint(thisPath, NULL, 180.0f, 140.0f);
    CGPathCloseSubpath(thisPath);

    // Create shape layer
    shapeLayer = [CAShapeLayer layer];
    shapeLayer.frame = self.view.bounds;
    shapeLayer.path = thisPath;
    shapeLayer.fillColor = [UIColor redColor].CGColor;

    [self.view.layer addSublayer:shapeLayer];

    // Add the animation
    CABasicAnimation* colorAnimation = [CABasicAnimation animationWithKeyPath:@"fillColor"];
    colorAnimation.duration = 4.0;
    colorAnimation.repeatCount = 1e100f;
    colorAnimation.autoreverses = YES;
    colorAnimation.fromValue = (id) [UIColor redColor].CGColor;
    colorAnimation.toValue = (id) [UIColor blueColor].CGColor;
    [shapeLayer addAnimation:colorAnimation forKey:@"animateColor"];
}
Run Code Online (Sandbox Code Playgroud)

这会按预期动画颜色偏移.当我把它移植到Monotouch时,我试过: …

cgcolor nsobject xamarin.ios ios

3
推荐指数
1
解决办法
1684
查看次数

标签 统计

cgcolor ×1

ios ×1

nsobject ×1

xamarin.ios ×1