创建扩展圈iOS

时间:2014-10-23 04:56:48

标签: ios objective-c

如何创建一个扩展加班的圈子。我想做这样的事情:

[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);
}];

1 个答案:

答案 0 :(得分:5)

该绘图代码在动画块中没有任何影响

请尝试以下方法:

// 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)];
}];