From 53106c876053bc935e20078966a8af69425cbb1a Mon Sep 17 00:00:00 2001 From: fish Date: Sun, 12 Jul 2026 21:27:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E7=AC=94=E8=AE=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E6=96=87=E6=9C=AC=E6=A1=86?= =?UTF-8?q?=E5=92=8C=E5=BA=95=E9=83=A8=E4=B8=A4=E4=B8=AA=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Note/FormatNoteViewController.swift | 68 ++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/Note/FormatNoteViewController.swift b/Note/FormatNoteViewController.swift index d585e46..1bf2534 100644 --- a/Note/FormatNoteViewController.swift +++ b/Note/FormatNoteViewController.swift @@ -9,10 +9,76 @@ import UIKit class FormatNoteViewController: UIViewController { + private var textView: UITextView! + private var iCloudButton: UIButton! + private var noteButton: UIButton! + override func viewDidLoad() { super.viewDidLoad() title = "格式化笔记" navigationItem.largeTitleDisplayMode = .never - view.backgroundColor = .systemBackground + view.backgroundColor = .systemGroupedBackground + setupUI() + } + + private func setupUI() { + textView = UITextView() + textView.translatesAutoresizingMaskIntoConstraints = false + textView.backgroundColor = .systemBackground + textView.layer.cornerRadius = 12 + textView.layer.masksToBounds = true + textView.font = UIFont.preferredFont(forTextStyle: .body) + textView.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12) + textView.isEditable = true + view.addSubview(textView) + + iCloudButton = createBottomButton(title: "iCloud 格式化", color: .systemBlue) + iCloudButton.addTarget(self, action: #selector(didTapiCloudButton), for: .touchUpInside) + view.addSubview(iCloudButton) + + noteButton = createBottomButton(title: "Note 格式化", color: .systemGreen) + noteButton.addTarget(self, action: #selector(didTapNoteButton), for: .touchUpInside) + view.addSubview(noteButton) + + let safeArea = view.safeAreaLayoutGuide + let buttonHeight: CGFloat = 52 + let spacing: CGFloat = 16 + + NSLayoutConstraint.activate([ + textView.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: spacing), + textView.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: spacing), + textView.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -spacing), + + iCloudButton.topAnchor.constraint(equalTo: textView.bottomAnchor, constant: spacing), + iCloudButton.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: spacing), + iCloudButton.trailingAnchor.constraint(equalTo: safeArea.centerXAnchor, constant: -spacing / 2), + iCloudButton.heightAnchor.constraint(equalToConstant: buttonHeight), + iCloudButton.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -spacing), + + noteButton.topAnchor.constraint(equalTo: textView.bottomAnchor, constant: spacing), + noteButton.leadingAnchor.constraint(equalTo: safeArea.centerXAnchor, constant: spacing / 2), + noteButton.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -spacing), + noteButton.heightAnchor.constraint(equalToConstant: buttonHeight), + noteButton.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -spacing) + ]) + } + + private func createBottomButton(title: String, color: UIColor) -> UIButton { + var config = UIButton.Configuration.filled() + config.title = title + config.baseBackgroundColor = color + config.baseForegroundColor = .white + config.cornerStyle = .medium + config.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16) + + let button = UIButton(configuration: config) + button.translatesAutoresizingMaskIntoConstraints = false + return button + } + + @objc private func didTapiCloudButton() { + } + + @objc private func didTapNoteButton() { } }