INNER CODE UNIT · Swift
layoutSubviews
wu9007/qrcode_scanner · ios/Classes/SwiftQrscanPlugin.swift:545
override func layoutSubviews() {
super.layoutSubviews()
let topBar: CGFloat = 56
let bottom: CGFloat = 96
let available = max(120, bounds.height - topBar - bottom)
let size = min(bounds.width * 0.72, available * 0.92)
let left = (bounds.width - size) / 2
let top = topBar + max(0, (available - size) / 2)
hole = CGRect(x: left, y: top, width: size, height: size)
line.frame = CGRect(x: hole.minX + 8, y: hole.minY + 8, width: hole.width - 16, height: 2)
hintLabel.frame = CGRect(x: hole.minX, y: hole.maxY + 16, width: hole.width, height: 40)
titleLabel.frame = CGRect(x: 56, y: max(8, hole.minY - 36), width: bounds.width - 112, height: 24)
setNeedsDisplay()
if running { start() }
}
override func draw(_ rect: CGRect) {
guard let ctx = UIGraphicsGetCurrentContext(), hole.width > 0 else { return }