gpt4 book ai didi

animation - swift Playground XCPShowView "Unable to satisfy constraints"

转载 作者:行者123 更新时间:2023-12-03 22:56:24 24 4
gpt4 key购买 nike

我正在尝试获取实时 View 以在 Swift Playground 中显示简单的动画。每当我导入 XCPlayground 框架以执行 XCPShowView 函数时,我都会收到此错误:

Playground 执行失败:错误:无法查找符号:_CGPointMake

其他一些“符号”的错误也发生了变化,包括 CGRectMake
在被建议修改我的代码以从诸如 CGRectMake 之类的方法中删除“make”之后,当我尝试为我的 View 设置动画时,我仍然从 Xcode 收到错误。错误信息真的很长,但基本上就是这样

“无法同时满足约束条件。
可能至少以下列表中的约束之一是您不想要的。”

这是我尝试使用的代码:

//Circle Button
class timerButtonGraphics: UIView {
override func drawRect(rect: CGRect) {
let colorGreen = UIColor(red: 0.310, green: 0.725, blue: 0.624, alpha: 1.000)
let colorRed = UIColor(red: 241/255, green: 93/255, blue: 79/255, alpha: 100)
var bounds = self.bounds
var center = CGPoint()
center.x = bounds.origin.x + bounds.size.width / 2
center.y = bounds.origin.y + bounds.size.height / 2
var radius = 61
var path:UIBezierPath = UIBezierPath()
path.addArcWithCenter(center, radius: CGFloat(radius), startAngle: CGFloat(0.0), endAngle: CGFloat(Float(M_PI) * 2.0), clockwise: true)
path.strokeWithBlendMode(kCGBlendModeNormal, alpha: 100)
path.lineWidth = 2
if strokeRed == true {
colorRed.setStroke()
}
else {
colorGreen.setStroke()
}
path.stroke()
}
var strokeRed = true
}

var test = timerButtonGraphics(frame: CGRect(x: 0, y: 400, width: 400, height: 400))

UIView.animateWithDuration(2.0, delay: 2, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: nil, animations: {
test.transform = CGAffineTransformMakeTranslation(0.5, 0)
}, completion: nil)

XCPShowView("Circle Animation", test)

最佳答案

试试这个,也许它能帮到你

test.setTranslatesAutoresizingMaskIntoConstraints(false)

关于animation - swift Playground XCPShowView "Unable to satisfy constraints",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25231688/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com