diff --git a/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift b/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift index 6113f86..0ce88c7 100644 --- a/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift +++ b/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift @@ -61,27 +61,16 @@ final class SpellingInputView: UIView, UITextFieldDelegate { accessory.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 52) accessory.backgroundColor = .clear - 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(red: 0.6, green: 0.75, blue: 0.95, alpha: 0.7).cgColor, UIColor(red: 0.3, green: 0.55, blue: 0.85, alpha: 0.45).cgColor] as CFArray, - locations: [0, 0.5] - )! - ctx.cgContext.drawLinearGradient(gradient, - start: CGPoint(x: 0, y: 0), end: CGPoint(x: 0, y: 44), options: []) + var glassConfig = UIButton.Configuration.glass() + glassConfig.title = "确认" + glassConfig.cornerStyle = .fixed + glassConfig.baseForegroundColor = .white + glassConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in + var outgoing = incoming + outgoing.font = .systemFont(ofSize: 16, weight: .semibold) + return outgoing } - glassButton.setBackgroundImage(bgImage, for: .normal) - - glassButton.setTitle("确认", for: .normal) - glassButton.setTitleColor(.white, for: .normal) - glassButton.titleLabel?.font = .systemFont(ofSize: 16, weight: .semibold) + let glassButton = UIButton(configuration: glassConfig) glassButton.addAction(UIAction { [weak self] _ in self?.onSubmit?() }, for: .touchUpInside)