【问题标题】:Error while using property 'CGRectGetWidth', it says it was replaced with 'CGRect.width'使用属性“CGRectGetWidth”时出错,它说它被替换为“CGRect.width”
【发布时间】:2018-02-14 11:46:56
【问题描述】:

当我使用这段代码时,我得到一个错误:

let d = translation.x / CGRectGetWidth(pan.view!.bounds) * 0.5

“CGRectGetWidth”已被属性“CGRect.width”替换

我该如何解决这个问题?

【问题讨论】:

    标签: swift cgrect


    【解决方案1】:

    您应该直接从bounds 属性中获取宽度。

    let d = translation.x / pan.view!.bounds.width * 0.5
    

    【讨论】:

      【解决方案2】:

      CGRectGetWidth在swift 3中已经被移除,现在可以直接获取宽度了

      let d = translation.x / (pan.view!.bounds.width) * 0.5
      

      希望它的作品..

      【讨论】:

      • 和4kman的回答没有区别,括号没意义。
      猜你喜欢
      • 2017-02-13
      • 1970-01-01
      • 1970-01-01
      • 2017-10-29
      • 1970-01-01
      • 2020-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多