From 4e509ce8e3d76d8f3b49a5a2ac7f5f35564f0412 Mon Sep 17 00:00:00 2001 From: v504 Date: Mon, 25 Aug 2025 18:00:08 +0800 Subject: [PATCH] Update QRCodeStyleView to improve logo handling by ensuring the selected logo is set as a background image only if it has a valid image, enhancing the visual presentation of QR codes. --- MyQrCode/Views/QRCodeStyleView.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MyQrCode/Views/QRCodeStyleView.swift b/MyQrCode/Views/QRCodeStyleView.swift index 830ed36..7f02d80 100644 --- a/MyQrCode/Views/QRCodeStyleView.swift +++ b/MyQrCode/Views/QRCodeStyleView.swift @@ -51,10 +51,11 @@ struct QRCodeStyleView: View { // 设置眼睛形状 d.design.shape.eye = selectedEyeType.eyeShape - // 如果有选择的Logo,设置背景图片 - if let selectedLogo = selectedLogo { - // 这里可以添加Logo图片设置 - // d.design.style.background = QRCode.FillStyle.Image(selectedLogo.image) + // 如果有选择的Logo,设置Logo + if let selectedLogo = selectedLogo, + let logoImage = selectedLogo.image { + // 设置Logo作为背景图片 + d.logoTemplate = QRCode.LogoTemplate.CircleCenter(image: logoImage.cgImage!) } return d