斯威夫特游乐场 XCPShowView "Unable to satisfy constraints"



我正试图获得一个实时视图来显示一个简单的动画在一个快速的游乐场。每当我导入XCPlayground框架来执行XCPShowView函数时,我都会得到这个错误:

Playground execution failed: error: Couldn't lookup symbols:_CGPointMake

其他一些"符号"的错误也发生了变化,包括CGRectMake
在被建议修改我的代码以从CGRectMake等方法中删除"make"后,当我尝试动画我的视图时,我仍然从Xcode得到一个错误。错误信息很长,但基本上是说

"Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want."

这是我试图工作的代码:

//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)

相关内容

最新更新