UIEdgeInsetsInsetRect' 已替换为实例方法 'CGRect.inset(by:)
UIEdgeInsetsInsetRect' has been replaced by instance method 'CGRect.inset(by:)
我错误地将我的项目更新到 Swift 4.2 而没有等待 pods 更新。我已经慢慢更新了我所有的代码,但有一行我似乎无法理解。
var animationRect = UIEdgeInsetsInsetRect(frame, UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding))
我收到的错误是,
UIEdgeInsetsInsetRect' has been replaced by instance method
'CGRect.inset(by:)
如有任何帮助,我们将不胜感激!
这个错误很容易解释。你可以这样使用它:
var animationRect = frame.inset(by: UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding))
或者干脆
var animationRect = frame.insetBy(dx: padding, dy: padding)
Swift 4.2 和 Xcode 10
之前是这样的 -
let bounds = UIEdgeInsetsEqualToEdgeInsets(view.bounds,view.safeAreaInsets)
现在 swift 4.2 -
let bounds = view.bounds.inset(by: view.safeAreaInsets)
UIEdgeInsets 在 Swift 4.2
Earlier version
let padding = UIEdgeInsets(top: 0, left: 40, bottom: 0, right: 5)
override func textRect(forBounds bounds: CGRect) -> CGRect {
return UIEdgeInsetsInsetRect(bounds, padding)
}
to swift 4.2 and Xcode 10
let padding = UIEdgeInsets(top: 0, left: 40, bottom: 0, right: 5)
override func textRect(forBounds bounds: CGRect) -> CGRect {
return rect.inset(by: GlobalClass.language == "ar" ? paddingR : padding)
}
此类 pods 的问题也可以通过为特定 pod 设置 SWIFT_VERSION
来解决。
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['MessageKit'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
end
end
end
end
我错误地将我的项目更新到 Swift 4.2 而没有等待 pods 更新。我已经慢慢更新了我所有的代码,但有一行我似乎无法理解。
var animationRect = UIEdgeInsetsInsetRect(frame, UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding))
我收到的错误是,
UIEdgeInsetsInsetRect' has been replaced by instance method 'CGRect.inset(by:)
如有任何帮助,我们将不胜感激!
这个错误很容易解释。你可以这样使用它:
var animationRect = frame.inset(by: UIEdgeInsets(top: padding, left: padding, bottom: padding, right: padding))
或者干脆
var animationRect = frame.insetBy(dx: padding, dy: padding)
Swift 4.2 和 Xcode 10
之前是这样的 -
let bounds = UIEdgeInsetsEqualToEdgeInsets(view.bounds,view.safeAreaInsets)
现在 swift 4.2 -
let bounds = view.bounds.inset(by: view.safeAreaInsets)
UIEdgeInsets 在 Swift 4.2
Earlier version
let padding = UIEdgeInsets(top: 0, left: 40, bottom: 0, right: 5) override func textRect(forBounds bounds: CGRect) -> CGRect { return UIEdgeInsetsInsetRect(bounds, padding) }
to swift 4.2 and Xcode 10
let padding = UIEdgeInsets(top: 0, left: 40, bottom: 0, right: 5) override func textRect(forBounds bounds: CGRect) -> CGRect { return rect.inset(by: GlobalClass.language == "ar" ? paddingR : padding) }
此类 pods 的问题也可以通过为特定 pod 设置 SWIFT_VERSION
来解决。
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['MessageKit'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
end
end
end
end