创建一个不断扩大的圆圈 iOS [英] Creating an expanding circle iOS

查看:91
本文介绍了创建一个不断扩大的圆圈 iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个扩大加班时间的圈子.我想做这样的事情:

How would go about creating a circle that expands overtime. I want to do something like this:

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

推荐答案

那个绘制代码不会影响动画块

That drawing code will have no affect in an animation block

请尝试以下操作:

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

这篇关于创建一个不断扩大的圆圈 iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆