【发布时间】:2018-02-14 11:46:56
【问题描述】:
当我使用这段代码时,我得到一个错误:
let d = translation.x / CGRectGetWidth(pan.view!.bounds) * 0.5
“CGRectGetWidth”已被属性“CGRect.width”替换
我该如何解决这个问题?
【问题讨论】:
当我使用这段代码时,我得到一个错误:
let d = translation.x / CGRectGetWidth(pan.view!.bounds) * 0.5
“CGRectGetWidth”已被属性“CGRect.width”替换
我该如何解决这个问题?
【问题讨论】:
您应该直接从bounds 属性中获取宽度。
let d = translation.x / pan.view!.bounds.width * 0.5
【讨论】:
CGRectGetWidth在swift 3中已经被移除,现在可以直接获取宽度了
let d = translation.x / (pan.view!.bounds.width) * 0.5
希望它的作品..
【讨论】: