相关疑难解决方法(0)

iPhone核心动画 - 画一个圆圈

我想创建一个动画.我可以解释这个问题的最佳方法是,如果你能想象画一个圆圈.它从顶部或12点钟开始,顺时针顺时针绘制,直到它在10秒左右的空间内变成一个完整的圆圈.

我得到的壁橱是使用Core Animation绘制一个围绕中心点旋转的点(使用此处的示例代码).但我对如何绘制圆圈感到茫然?任何建议都非常欢迎.

非常感谢 :)

iphone core-animation

48
推荐指数
2
解决办法
5万
查看次数

画出一个圆圈的一部分

对于iPhone应用程序,我想绘制一个圆圈,仅用于填充x百分比.

像这样的东西:

替代文字

我没有问题计算半径,度数或弧度,这是没有问题的.绘制圆圈也已完成.但是如何让iPhone SDK绘制已填充的部分.

我可以画一个大小的矩形,但不是圆的一部分.

我只想在一个正常的背景下绘制它.

希望有人能在这里给我任何指示.

iphone cocoa-touch objective-c

25
推荐指数
4
解决办法
2万
查看次数

使用圆UIBezierPath和CABasicAnimation为CAShapeLayer设置动画

我想在15秒内将角度从0度设置为360度.

动画很怪异.我知道这可能是一个开始/结束角度问题,我已经遇到了圆形动画的那种问题,但我不知道如何解决这个问题.

var circle_layer=CAShapeLayer()
var circle_anim=CABasicAnimation(keyPath: "path")

func init_circle_layer(){
    let w=circle_view.bounds.width
    let center=CGPoint(x: w/2, y: w/2)

    //initial path
    let start_angle:CGFloat = -0.25*360*CGFloat.pi/180
    let initial_path=UIBezierPath(arcCenter: center, radius: w/2, startAngle: start_angle, endAngle: start_angle, clockwise: true)
    initial_path.addLine(to: center)

    //final path
    let end_angle:CGFloat=start_angle+360*CGFloat(CGFloat.pi/180)
    let final_path=UIBezierPath(arcCenter: center, radius: w/2, startAngle: start_angle, endAngle: end_angle, clockwise: true)
    final_path.addLine(to: center)

    //init layer
    circle_layer.path=initial_path.cgPath
    circle_layer.fillColor=UIColor(hex_code: "EA535D").cgColor
    circle_view.layer.addSublayer(circle_layer)

    //init anim
    circle_anim.duration=15
    circle_anim.fromValue=initial_path.cgPath
    circle_anim.toValue=final_path.cgPath
    circle_anim.isRemovedOnCompletion=false
    circle_anim.fillMode=kCAFillModeForwards
    circle_anim.delegate=self
}

func start_circle_animation(){
    circle_layer.add(circle_anim, forKey: "circle_anim")
}
Run Code Online (Sandbox Code Playgroud)

我希望从0度开始顶部并在完整巡回赛后完成顶部: 在此输入图像描述

在此输入图像描述

cabasicanimation cashapelayer ios uibezierpath swift

4
推荐指数
1
解决办法
3522
查看次数

iOS:如何使用NSTimer逐步绘制圆圈

我想逐步绘制一个圆圈(只有圆圈的边框)(就像动画计时器一样).1旋转等于1天(24小时).我真的不知道该怎么办.

我做的步骤

1)我已经尝试过https://github.com/danielamitay/DACircularProgress(这是太宽泛的进展)

2)我试图绘制一个有很多弧的圆.

你能给我一些代码吗?我真的很困惑.提前致谢.

编辑

我想使用NSTimer,因为我有一个允许用户停止绘制圆形的按钮.如果用户再次触摸按钮,则必须继续绘制.

geometry objective-c cgcontext ios

3
推荐指数
1
解决办法
7718
查看次数

Swift 3:将动画的圆弧颜色填充添加到UIBezierPath

我希望为饼图的一部分的颜色填充设置动画。我通过UIBezierPath()为每个饼图创建一个饼图来创建饼图,然后使用该addArc方法指定圆弧的大小/约束。要设置饼图段的动画,我希望弧的颜色填充从圆的中心到半径末端进行动画处理。但是,我遇到了麻烦。我听说strokeEnd keyPath0到的动画1应该可以工作,但是弧上没有发生动画(弧仅在应用程序启动时出现)。

let rad = 2 * Double.pi
let pieCenter: CGPoint = CGPoint(x: frame.width / 2, y: frame.height / 2)
var start: Double = 0
for i in 0...data.count - 1 {
    let size: Double = Double(data[i])! / 100 // the percentege of the circle that the given arc will take
    let end: Double = start + (size * rad)

    let path = UIBezierPath()
    path.move(to: pieCenter)
    path.addArc(withCenter: pieCenter, radius: frame.width …
Run Code Online (Sandbox Code Playgroud)

animation core-graphics cashapelayer ios swift

1
推荐指数
1
解决办法
2006
查看次数