INNER CODE UNIT · Swift
available
wu9007/qrcode_scanner · ios/Classes/SwiftQrscanPlugin.swift:549
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 }
ctx.setFillColor(UIColor(white: 0, alpha: 0.55).cgColor)
ctx.fill(CGRect(x: 0, y: 0, width: bounds.width, height: hole.minY))
ctx.fill(CGRect(x: 0, y: hole.maxY, width: bounds.width, height: bounds.height - hole.maxY))
ctx.fill(CGRect(x: 0, y: hole.minY, width: hole.minX, height: hole.height))