Skip to content

Instantly share code, notes, and snippets.

@sanllier
Created March 22, 2018 11:14
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanllier/7737ee99a427e93cd847d9f516e8b1c4 to your computer and use it in GitHub Desktop.
Save sanllier/7737ee99a427e93cd847d9f516e8b1c4 to your computer and use it in GitHub Desktop.
@objc func _needsDoubleUpdateConstraintsPass() -> Bool {
return true
}
override var intrinsicContentSize: CGSize {
  return attributedText?.size(forWidth: (engineBounds ?? bounds).width) ?? .zero
}
var engineBounds: CGRect? {
let objcSelector = "_nsis_compatibleBoundsInEngine:")
    typealias CFunction = @convention(c) (AnyObject, Selector, Any) -> CGRect
   
let impl = class_getMethodImplementation(type(of: self).self, objcSelector)
    let callableImpl = unsafeBitCast(impl, to: CFunction.self)
   
return layoutEngine.flatMap { callableImpl(self, objcSelector, $0) }
}
var layoutEngine: Any? {
let objcSelector = "_nsli_layoutEngine:")
    typealias CFunction = @convention(c) (AnyObject, Selector) -> Any
   
let impl = class_getMethodImplementation(type(of: self).self, objcSelector)
    let callableImpl = unsafeBitCast(impl, to: CFunction.self)
   
return callableImpl(self, objcSelector)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment