创build一个扩展圈iOS

如何创build一个扩大加class的圈子? 我想要做这样的事情:

[UIView animateWithDuration:5 animations:^(void){ /* Expand the circle */ // Get the contextRef CGContextRef contextRef = UIGraphicsGetCurrentContext(); // Set the border width CGContextSetLineWidth(contextRef, 1.0); // Set the circle fill color to Transparent CGContextSetRGBFillColor(contextRef, 0.0, 0.0, 0.0, 0.0); // Set the cicle border color to BLUE CGContextSetRGBStrokeColor(contextRef, 0.0, 0.0, 255.0, 1.0); // Fill the circle with the fill color CGContextFillEllipseInRect(contextRef, self.view.frame); // Draw the circle border CGContextStrokeEllipseInRect(contextRef, self.view.frame); }]; 

该绘图代码在animation块中不会有任何影响

尝试以下方法:

 // Create a view with a corner radius as the circle UIView* circle = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; [circle.layer setCornerRadius:circle.frame.size.width / 2]; [circle setBackgroundColor:[UIColor redColor]]; [self.view addSubview:circle]; [UIView animateWithDuration:5 animations:^{ // Animate it to double the size const CGFloat scale = 2; [circle setTransform:CGAffineTransformMakeScale(scale, scale)]; }];