相关疑难解决方法(0)

如何沿曲线路径设置视图或图像的移动动画?

我正在开发一个商务应用程序.当我将一个项目添加到购物车时,我想创建一个效果,其中项目的图像遵循弯曲的路径,最终在购物车选项卡上.

如何沿这样的曲线创建图像动画?

iphone cocoa-touch core-animation objective-c ios

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

找到三次贝塞尔曲线上的点的切线

对于具有通常的四个点a,b,c和d的三次Bézier曲线,

对于给定值t,

如何最优雅地找到那一点的切线

bezier ios swift

22
推荐指数
3
解决办法
2万
查看次数

如何获得CGPath曲线或四边形曲线中的所有点

我使用该方法制作了四条曲线路径CGPathAddQuadCurveToPoint.我完美地完成了这条道路.但是,我想知道参与路径的所有坐标点.

有没有办法检索路径中的所有坐标点?

如果没有,你有任何其他解决方案用于以数学方式检索曲线中的所有点.

提前谢谢,Vamshi

iphone cocoa bezier core-animation core-graphics

18
推荐指数
2
解决办法
8040
查看次数

沿着简单的三次贝塞尔曲线找到一个点,一个给定的距离.(在iPhone上!)

想象一下,你有一个完全正常的四点贝塞尔曲线(两点和两个控制点)使用curveToPoint创建:controlPoint1:controlPoint2:在你的cocoa应用程序中:

简单的三次贝塞尔曲线例子
你如何沿曲线找到点(和切线)?


后来:对于基于Michal的答案的完整,简化的解决方案,请点击:
找到立方贝塞尔曲线上的点的切线(在iPhone上)

只需复制并粘贴代码:https://stackoverflow.com/a/31317254/294884

iphone bezier ipad

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

如何从UIBezierPath生成CGPoint-Array(沿给定路径触摸滑动对象)

我有一个UIBezierPath(曲线像'8',只有4个点),我需要制作一些CGPoint-Array.有任何想法吗?感谢名单!

编辑:

我有这样的bezier初始化

-(void) initBezier
{
    theBezierPath = [UIBezierPath bezierPath];    
    [theBezierPath moveToPoint:P(211.00, 31.00)];
    [theBezierPath addCurveToPoint:P(870.00, 191.00) controlPoint1:P(432.00, -11.00) controlPoint2:P(593.00, 209.00)];
    [theBezierPath addCurveToPoint:P(731.00, 28.00) controlPoint1:P(1061.95, 178.53) controlPoint2:P(944.69, 5.78)];
    [theBezierPath addCurveToPoint:P(189.00, 190.00) controlPoint1:P(529.00, 49.00) controlPoint2:P(450.00, 189.00)];
    [theBezierPath addCurveToPoint:P(211.00, 31.00) controlPoint1:P(-33.01, 190.85) controlPoint2:P(71.00, 37.00)];
}
Run Code Online (Sandbox Code Playgroud)

我用它动画一个物体

anim = [CAKeyframeAnimation animationWithKeyPath:@"emitterPosition"];
anim.path = theBezierPath.CGPath;
anim.calculationMode = kCAAnimationCubicPaced;
anim.repeatCount = HUGE_VALF;
anim.duration = tme;
Run Code Online (Sandbox Code Playgroud)

我想逐个像素地(通过触摸位置)为路径上的对象设置动画.我希望对象将触摸的给定坐标"捕捉"到曲线上的最近点,以便沿着路径触摸滑动对象.

objective-c cgpoint ios uibezierpath

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

CAShapeLayer.线是否通过该点?

我使用CAShapeLayer在屏幕上画一条线.在touchesEnded方法中,我想检查"线是否通过该点?".在我的代码中,当我按下屏幕的任何部分时,该方法包含返回始终为true.也许,我在line.frame =(view?.bounds)遇到了问题!.我该如何解决?对不起,我的英语不好.

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

    let touch = touches.first
    let firstPosition = touch?.location(in: self)

    if atPoint(firstPosition!) == lvl1 {

        let firstPositionX = firstPosition?.x
        let firstPositionY = frame.size.height - (firstPosition?.y)!
        view?.layer.addSublayer(line)
        line.lineWidth = 8
        let color = #colorLiteral(red: 0.8078431487, green: 0.02745098062, blue: 0.3333333433, alpha: 1).cgColor
        line.strokeColor = color
        line.fillColor = nil
        line.frame = (view?.bounds)!
        path.move(to: CGPoint(x: firstPositionX!, y: firstPositionY))

    }

}

override func touchesMoved(_ touches: …
Run Code Online (Sandbox Code Playgroud)

ios swift swift2 swift3

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