这是我的问题:
let view = UIView()
var alpha: CGFloat = 0.2
view.alpha = alpha
if view.alpha == alpha {
print("true: \(view.alpha)")
} else {
print("false: \(view.alpha)") // false: 0.200000002980232
}
alpha = 0.5
view.alpha = alpha
if view.alpha == alpha {
print("true: \(view.alpha)") // true: 0.5
} else {
print("false: \(view.alpha)")
}
alpha = 0.9
view.alpha = alpha
if view.alpha == alpha {
print("true: \(view.alpha)")
} else {
print("false: \(view.alpha)") // false: 0.899999976158142
}
var factor:CGFloat = 0.2
view.contentScaleFactor = factor
if view.contentScaleFactor == factor {
print("true: \(view.contentScaleFactor)") // true: 0.2
} else {
print("false: \(view.contentScaleFactor)")
}
上面的代码使用Xcode 7.3& Swift 2.2
我不确定是否已经存在这个问题的rdar地址。
知道为什么吗?或者从什么时候开始?