Commit 22eed633 authored by Steven杜宇's avatar Steven杜宇

// 自定义textView

parent 705c2e0c
...@@ -172,6 +172,7 @@ ...@@ -172,6 +172,7 @@
0435FA7F2BA178C100024EAE /* YHCommonAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */; }; 0435FA7F2BA178C100024EAE /* YHCommonAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */; };
0435FA812BA186D600024EAE /* YHMyFileMethodTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA802BA186D600024EAE /* YHMyFileMethodTableViewCell.swift */; }; 0435FA812BA186D600024EAE /* YHMyFileMethodTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA802BA186D600024EAE /* YHMyFileMethodTableViewCell.swift */; };
0435FA832BA2DEB100024EAE /* YHCardButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA822BA2DEB100024EAE /* YHCardButton.swift */; }; 0435FA832BA2DEB100024EAE /* YHCardButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0435FA822BA2DEB100024EAE /* YHCardButton.swift */; };
04395F8A2CEDB26500D3005C /* YHAutoTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04395F892CEDB26500D3005C /* YHAutoTextView.swift */; };
043B0A352C1190C6008A9BBA /* YHSelectFileSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043B0A342C1190C6008A9BBA /* YHSelectFileSheetView.swift */; }; 043B0A352C1190C6008A9BBA /* YHSelectFileSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043B0A342C1190C6008A9BBA /* YHSelectFileSheetView.swift */; };
043BA8752C241B38006EF02D /* YHAddFriendCardCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043BA8742C241B38006EF02D /* YHAddFriendCardCell.swift */; }; 043BA8752C241B38006EF02D /* YHAddFriendCardCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043BA8742C241B38006EF02D /* YHAddFriendCardCell.swift */; };
043BA8892C244129006EF02D /* people_head.json in Resources */ = {isa = PBXBuildFile; fileRef = 043BA8882C244129006EF02D /* people_head.json */; }; 043BA8892C244129006EF02D /* people_head.json in Resources */ = {isa = PBXBuildFile; fileRef = 043BA8882C244129006EF02D /* people_head.json */; };
...@@ -1199,6 +1200,7 @@ ...@@ -1199,6 +1200,7 @@
0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCommonAlertView.swift; sourceTree = "<group>"; }; 0435FA7E2BA178C100024EAE /* YHCommonAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCommonAlertView.swift; sourceTree = "<group>"; };
0435FA802BA186D600024EAE /* YHMyFileMethodTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyFileMethodTableViewCell.swift; sourceTree = "<group>"; }; 0435FA802BA186D600024EAE /* YHMyFileMethodTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyFileMethodTableViewCell.swift; sourceTree = "<group>"; };
0435FA822BA2DEB100024EAE /* YHCardButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCardButton.swift; sourceTree = "<group>"; }; 0435FA822BA2DEB100024EAE /* YHCardButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCardButton.swift; sourceTree = "<group>"; };
04395F892CEDB26500D3005C /* YHAutoTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAutoTextView.swift; sourceTree = "<group>"; };
043B0A342C1190C6008A9BBA /* YHSelectFileSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSelectFileSheetView.swift; sourceTree = "<group>"; }; 043B0A342C1190C6008A9BBA /* YHSelectFileSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSelectFileSheetView.swift; sourceTree = "<group>"; };
043BA8742C241B38006EF02D /* YHAddFriendCardCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAddFriendCardCell.swift; sourceTree = "<group>"; }; 043BA8742C241B38006EF02D /* YHAddFriendCardCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAddFriendCardCell.swift; sourceTree = "<group>"; };
043BA8882C244129006EF02D /* people_head.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = people_head.json; sourceTree = "<group>"; }; 043BA8882C244129006EF02D /* people_head.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = people_head.json; sourceTree = "<group>"; };
...@@ -5205,6 +5207,7 @@ ...@@ -5205,6 +5207,7 @@
0418921E2C91BAAC00B9FB94 /* YHBaseDynamicCornerRadiusView.swift */, 0418921E2C91BAAC00B9FB94 /* YHBaseDynamicCornerRadiusView.swift */,
04F243622C9D4C9700DF2C74 /* YHBaseCornerRadiusBorderView.swift */, 04F243622C9D4C9700DF2C74 /* YHBaseCornerRadiusBorderView.swift */,
04F2432E2C94704200DF2C74 /* YHPaddedLabel.swift */, 04F2432E2C94704200DF2C74 /* YHPaddedLabel.swift */,
04395F892CEDB26500D3005C /* YHAutoTextView.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -5808,6 +5811,7 @@ ...@@ -5808,6 +5811,7 @@
044EE24C2C94396E00A2FE3A /* YHResignCertificatePassportTableViewCell.swift in Sources */, 044EE24C2C94396E00A2FE3A /* YHResignCertificatePassportTableViewCell.swift in Sources */,
04F2435B2C9D140C00DF2C74 /* YHHKRecordsTitleCell.swift in Sources */, 04F2435B2C9D140C00DF2C74 /* YHHKRecordsTitleCell.swift in Sources */,
044F393A2CB7772D007CA277 /* YHVisaRenewalGuideRemarkCell.swift in Sources */, 044F393A2CB7772D007CA277 /* YHVisaRenewalGuideRemarkCell.swift in Sources */,
04395F8A2CEDB26500D3005C /* YHAutoTextView.swift in Sources */,
041892242C91BCF100B9FB94 /* YHResignRoundCellType.swift in Sources */, 041892242C91BCF100B9FB94 /* YHResignRoundCellType.swift in Sources */,
04912F7A2CB7A5F400CC3105 /* YHResignHaveAppointedApplicantsInfoCell.swift in Sources */, 04912F7A2CB7A5F400CC3105 /* YHResignHaveAppointedApplicantsInfoCell.swift in Sources */,
0430E6722C749E74000511E2 /* YHAdopterBirthViewController.swift in Sources */, 0430E6722C749E74000511E2 /* YHAdopterBirthViewController.swift in Sources */,
......
//
// YHAutoTextView.swift
// galaxy
//
// Created by Dufet on 2024/11/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAutoTextView: UITextView, UITextViewDelegate {
override open var text: String! {
didSet {
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
var placeHolder: String = "" {
didSet {
placeholderLabel.text = placeHolder
}
}
let placeholderLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = UIColor.lightGray
label.font = UIFont.PFSC_R(ofSize: 15)
return label
}()
override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer)
delegate = self
isScrollEnabled = false // 禁止滚动
translatesAutoresizingMaskIntoConstraints = false
clearsOnInsertion = true
self.addSubview(placeholderLabel)
placeholderLabel.snp.makeConstraints { make in
make.top.equalTo(5)
make.left.equalTo(5)
make.right.equalTo(-5)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// UITextViewDelegate 方法
func textViewDidChange(_ textView: UITextView) {
// 更新自身的高度
invalidateIntrinsicContentSize()
placeholderLabel.isHidden = !textView.text.isEmpty
}
override var intrinsicContentSize: CGSize {
// 计算内容的尺寸
let size = sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude))
return CGSize(width: size.width, height: size.height)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment