1.i创建了CAshapelayer,并且还在CAshapelayer中插入了一个成功的标签,但现在我试图在图层中设置图像,但它不起作用。无法为半成形图层设置图像
帮助我放大此图层的动画。
CAShapeLayer *circleLayer = [CAShapeLayer layer]; [circleLayer setPath:[[UIBezierPath bezierPathWithOvalInRect:CGRectMake(50, 250, 100, 100)] CGPath]]; circleLayer.contents = (id)[[UIImage imageNamed:@"001-forward.png"] CGImage]; circleLayer.contentsGravity=kCAGravityResize; // circleLayer.masksToBounds = YES; [circleLayer setStrokeColor:[[UIColor brownColor] CGColor]]; [circleLayer setFillColor:[[UIColor clearColor] CGColor]]; [[self.view layer] addSublayer:circleLayer]; CATextLayer *label = [[CATextLayer alloc] init]; [label setFont:@"Helvetica-Bold"]; [label setFontSize:15]; [label setFrame:CGRectMake(50,300, 100, 50)]; [label setString:@"GM"]; [label setAlignmentMode:kCAAlignmentCenter]; [label setForegroundColor:[[UIColor greenColor] CGColor]]; [circleLayer addSublayer:label];
从图像名称中删除.png,然后尝试代码,看它是否设置图像? – 3stud1ant3
你放大动画的意思,你可以发布一个gif或我们可以看到的东西吗? –
@ 3stud1ant3没有任何变化 – Abhiram