From 885f56218eae5e912a8dd566a940370b31d455cc Mon Sep 17 00:00:00 2001 From: fish Date: Mon, 20 Jul 2026 21:47:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=8C=89=E9=92=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=20Liquid=20Glass=20=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- .../Views/SpellingInputView.swift | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift b/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift index 6bab347..2c9b975 100644 --- a/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift +++ b/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift @@ -60,17 +60,44 @@ final class SpellingInputView: UIView, UITextFieldDelegate { let accessory = UIView() accessory.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 52) accessory.backgroundColor = .clear - let confirmButton = UIButton(type: .system) - confirmButton.setTitle("确认", for: .normal) - confirmButton.titleLabel?.font = .systemFont(ofSize: 17, weight: .semibold) - confirmButton.addAction(UIAction { [weak self] _ in + + let glassButton = UIButton(type: .custom) + glassButton.layer.cornerRadius = 14 + glassButton.layer.borderWidth = 0.5 + glassButton.layer.borderColor = UIColor(white: 1, alpha: 0.6).cgColor + glassButton.clipsToBounds = true + + let renderer = UIGraphicsImageRenderer(size: CGSize(width: 60, height: 44)) + let bgImage = renderer.image { ctx in + let gradient = CGGradient( + colorsSpace: CGColorSpaceCreateDeviceRGB(), + colors: [UIColor(white: 1, alpha: 0.65).cgColor, UIColor(white: 1, alpha: 0.2).cgColor] as CFArray, + locations: [0, 0.5] + )! + ctx.cgContext.drawLinearGradient(gradient, + start: CGPoint(x: 0, y: 0), end: CGPoint(x: 0, y: 44), options: []) + } + glassButton.setBackgroundImage(bgImage, for: .normal) + + var titleConfig = UIButton.Configuration.plain() + titleConfig.title = "确认" + titleConfig.baseForegroundColor = .white + titleConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in + var outgoing = incoming + outgoing.font = .systemFont(ofSize: 16, weight: .semibold) + return outgoing + } + glassButton.configuration = titleConfig + glassButton.addAction(UIAction { [weak self] _ in self?.onSubmit?() }, for: .touchUpInside) - confirmButton.translatesAutoresizingMaskIntoConstraints = false - accessory.addSubview(confirmButton) + glassButton.translatesAutoresizingMaskIntoConstraints = false + accessory.addSubview(glassButton) NSLayoutConstraint.activate([ - confirmButton.trailingAnchor.constraint(equalTo: accessory.trailingAnchor, constant: -8), - confirmButton.topAnchor.constraint(equalTo: accessory.topAnchor, constant: 8) + glassButton.trailingAnchor.constraint(equalTo: accessory.trailingAnchor, constant: -15), + glassButton.centerYAnchor.constraint(equalTo: accessory.centerYAnchor), + glassButton.widthAnchor.constraint(equalToConstant: 60), + glassButton.heightAnchor.constraint(equalToConstant: 44) ]) hiddenField.inputAccessoryView = accessory