Error[8]: Undefined offset: 14, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述这是我的代码: @objc func drawForm() { i = Int(arc4random_uniform(UInt32(formNames.count))) var drawPath = actualFormNamesFromFormClass[i] shapeLayer.fillColor = UIColor.clear.cgColor shapeLa 这是我的代码:

@objc func drawForm() {    i = Int(arc4random_uniform(UInt32(formnames.count)))    var drawPath = actualFormnamesFromFormClass[i]    shapeLayer.fillcolor = UIcolor.clear.cgcolor    shapeLayer.strokecolor = UIcolor.black.cgcolor    shapeLayer.linewidth = 6    shapeLayer.frame = CGRect(x: -115,y: 280,wIDth: 350,height: 350)    var paths: [UIBezIErPath] = drawPath()    let shapeBounds = shapeLayer.bounds    let mirror = CGAffinetransform(scaleX: 1,y: -1)    let translate = CGAffinetransform(translationX: 0,y: shapeBounds.size.height)    let concatenated = mirror.concatenating(translate)    for path in paths {        path.apply(concatenated)    }    guard let path = paths.first else {        return    }    paths.dropFirst()        .forEach {            path.append(removeFromSuperlayer())    }    shapeLayer.transform = CAtransform3DMakeScale(0.6,0.6,0)    shapeLayer.path = path.cgPath    self.vIEw.layer.addSublayer(shapeLayer)    strokeEndAnimation.duration = 30.0    strokeEndAnimation.fromValue = 0.0    strokeEndAnimation.tovalue = 1.0    shapeLayer.add(strokeEndAnimation,forKey: nil)}

这段代码为shapeLayer路径的绘图设置了动画,但我无法在网上找到任何关于删除此图层并停止此基本动画或删除被绘制的cgPath的内容…任何帮助将不胜感激!

解决方法 你说:

I can’t find anything online about removing this layer …

这是

shapeLayer.removeFromSuperlayer()
.

removeAllAnimations

你继续说:

… and stopPing this basic animation …

这是

shapeLayer.removeAllAnimations()

presentation

注意,这会立即将strokeEnd(或您动画的任何属性)更改回其先前的值.如果你想在你停止它的地方“冻结”它,你必须抓住

if let strokeEnd = shapeLayer.presentation()?.strokeEnd {    shapeLayer.removeAllAnimations()    shapeLayer.strokeEnd = strokeEnd}
图层(它捕捉图层的属性,因为它们是动画中期),保存适当的属性,然后更新你的图层的属性正在停止动画:

cgPath

最后,你继续说:

… or removing the

shapeLayer.path = nil
that gets drawn.

只需将其设置为nil:

CAShapeLayer

顺便说一句,当您浏览CABasicAnimationCALayer的文档时,请不要忘记查看其超类的文档,分别是CAAnimationCAPropertyAnimation»[+++].最重要的是,当四处寻找有关特定类的属性或方法的文档时,您通常需要深入研究超类以查找相关信息.

最后,Core Animation Programming Guide是很好的介绍,虽然它的例子在Objective-C中,但所有概念都适用于Swift.

总结

以上是内存溢出为你收集整理的swift – 如何从我的UIView中删除CAShapeLayer和CABasicAnimation?全部内容,希望文章能够帮你解决swift – 如何从我的UIView中删除CAShapeLayer和CABasicAnimation?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
swift – 如何从我的UIView中删除CAShapeLayer和CABasicAnimation?_app_内存溢出

swift – 如何从我的UIView中删除CAShapeLayer和CABasicAnimation?

swift – 如何从我的UIView中删除CAShapeLayer和CABasicAnimation?,第1张

概述这是我的代码: @objc func drawForm() { i = Int(arc4random_uniform(UInt32(formNames.count))) var drawPath = actualFormNamesFromFormClass[i] shapeLayer.fillColor = UIColor.clear.cgColor shapeLa 这是我的代码:

@objc func drawForm() {    i = Int(arc4random_uniform(UInt32(formnames.count)))    var drawPath = actualFormnamesFromFormClass[i]    shapeLayer.fillcolor = UIcolor.clear.cgcolor    shapeLayer.strokecolor = UIcolor.black.cgcolor    shapeLayer.linewidth = 6    shapeLayer.frame = CGRect(x: -115,y: 280,wIDth: 350,height: 350)    var paths: [UIBezIErPath] = drawPath()    let shapeBounds = shapeLayer.bounds    let mirror = CGAffinetransform(scaleX: 1,y: -1)    let translate = CGAffinetransform(translationX: 0,y: shapeBounds.size.height)    let concatenated = mirror.concatenating(translate)    for path in paths {        path.apply(concatenated)    }    guard let path = paths.first else {        return    }    paths.dropFirst()        .forEach {            path.append(removeFromSuperlayer())    }    shapeLayer.transform = CAtransform3DMakeScale(0.6,0.6,0)    shapeLayer.path = path.cgPath    self.vIEw.layer.addSublayer(shapeLayer)    strokeEndAnimation.duration = 30.0    strokeEndAnimation.fromValue = 0.0    strokeEndAnimation.tovalue = 1.0    shapeLayer.add(strokeEndAnimation,forKey: nil)}

这段代码为shapeLayer路径的绘图设置了动画,但我无法在网上找到任何关于删除此图层并停止此基本动画或删除被绘制的cgPath的内容…任何帮助将不胜感激!

解决方法 你说:

I can’t find anything online about removing this layer …

这是

shapeLayer.removeFromSuperlayer()
.

removeAllAnimations

你继续说:

… and stopPing this basic animation …

这是

shapeLayer.removeAllAnimations()

presentation

注意,这会立即将strokeEnd(或您动画的任何属性)更改回其先前的值.如果你想在你停止它的地方“冻结”它,你必须抓住

if let strokeEnd = shapeLayer.presentation()?.strokeEnd {    shapeLayer.removeAllAnimations()    shapeLayer.strokeEnd = strokeEnd}
图层(它捕捉图层的属性,因为它们是动画中期),保存适当的属性,然后更新你的图层的属性正在停止动画:

cgPath

最后,你继续说:

… or removing the

shapeLayer.path = nil
that gets drawn.

只需将其设置为nil:

CAShapeLayer

顺便说一句,当您浏览CABasicAnimationCALayer的文档时,请不要忘记查看其超类的文档,分别是CAAnimationCAPropertyAnimation».最重要的是,当四处寻找有关特定类的属性或方法的文档时,您通常需要深入研究超类以查找相关信息.

最后,Core Animation Programming Guide是很好的介绍,虽然它的例子在Objective-C中,但所有概念都适用于Swift.

总结

以上是内存溢出为你收集整理的swift – 如何从我的UIView中删除CAShapeLayer和CABasicAnimation?全部内容,希望文章能够帮你解决swift – 如何从我的UIView中删除CAShapeLayer和CABasicAnimation?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/999757.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存