swift - 使用属性 'CGRectGetWidth' 时出错,它说它已替换为 'CGRect.width'

标签 swift cgrect

当我使用此代码时,出现错误:

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

'CGRectGetWidth' has been replaced by property 'CGRect.width'

我该如何解决这个问题?

最佳答案

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

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

关于swift - 使用属性 'CGRectGetWidth' 时出错,它说它已替换为 'CGRect.width',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48786472/

相关文章:

ios - Realm 模型的关系 - Swift

swift - 如何快速将 sockaddr_in 转换为 sockaddr

swift - 如何向 UINavigationItem 添加操作?

ios - 是否有检测线是否接触矩形的功能

ios - 具有空值的 CGRect?

ios - 旋转时更改 UIScreen 的大小

ios - 获取 UIButton 在 UITableViewCell 中的位置

ios - 用模型填充viewModel数组

ios - 将变量设置为等于 View 的框架,而当 View 的框架更改时,值不会更改

swift - usedRectForTextContainer 大小错误与 NSAttributedString?