导入UIKit
CustomView类:UIView {
override func draw(_ rect: CGRect) {
// Drawing code
let context = UIGraphicsGetCurrentContext()
let h = context?.height
debugPrint(h) // printed value: Optional(0)
}
}
输出:
[ Unknown process name ] CGBitmapContextGetHeight: invalid context 0x----.
If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.