圈内圈

时间:2017-07-31 22:01:08

标签: ios swift uiimageview uiimage uipangesturerecognizer

尝试修复错误:

  

二元运算符'<&#;不能应用于CGFloat'类型的操作数。和' Double'。

我已尝试let centerRadius: CGFloat = 37.5let whiteDotRadius: CGFloat = 23.5.代码运行,但当whiteDot位于中心内时,不会打印语句。我该如何修复错误消息?

 let centerRadius = 37.5
    let whiteDotRadius = 23.5

    let whiteDotDist = hypot(center.center.x - whiteDot.center.x, center.center.y - whiteDot.center.y - whiteDot.center.y)

    if whiteDotDist < centerRadius - whiteDotRadius {
        print("Inside")
    }

screenshot from the circles

1 个答案:

答案 0 :(得分:2)

将您的if语句更改为此

if CFGFloat(whiteDotDist) < CFGFloat(centerRadius - whiteDotRadius)

希望这有帮助!