Music_Player3/MusicPlayer/MP/ViewControllers/Center(个人资源)/RenameViewController.swift
Mr.zhou 96147c5e37 项目:Musicoo
版本:A面 1.0
构建:1.1
更新内容:对项目A面功能的实现,经测试确定各项功能无问题。
更新时间:2024年4月12日 11:20
上传状态:已上传App Connect
2024-04-12 11:19:58 +08:00

46 lines
1.4 KiB
Swift

//
// RenameViewController.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/4/7.
//
import UIKit
class RenameViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var textField: UITextField!{
didSet{
textField.attributedPlaceholder = NSAttributedString(string: "Placeholder", attributes: [NSAttributedString.Key.foregroundColor:UIColor.init(hex: "#EBEBF5"), NSAttributedString.Key.font : UIFont.systemFont(ofSize: 13, weight: .regular)])
textField.delegate = self
}
}
var renameBlock:((String) -> Void)?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let text = (textField.text! as NSString).replacingCharacters(in: range, with: string)
guard text.count <= 60 else {
return false
}
return true
}
@IBAction func confirmClick(_ sender: UIButton) {
guard let text = textField.text, text != "" else {
return
}
dismiss(animated: true) {
[weak self] in
if self?.renameBlock != nil {
self?.renameBlock!(text)
}
}
}
@IBAction func cancelClick(_ sender: UIButton) {
dismiss(animated: true)
}
}