【问题标题】:Creating an expanding circle iOS创建一个扩大的圈子 iOS
【发布时间】:2014-10-23 18:35:04
【问题描述】:

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

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

【问题讨论】:

标签: ios objective-c


【解决方案1】:

该绘图代码不会影响动画块

请尝试以下方法:

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

【讨论】:

  • 嘿伙计 - 只为 帧的大小 设置动画不是更好吗??
  • @JoeBlow Blow 这就是我最初尝试的方法,但是您还需要为圆角半径设置动画,这给我带来了问题。我确信这是可能的,只是不知道如何。
  • @SomeGuy 你介意看看我刚刚发布的这个问题吗?谢谢! stackoverflow.com/questions/26538788/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-18
  • 1970-01-01
  • 2015-04-12
  • 1970-01-01
相关资源
最近更新 更多