Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
25820cf8
Commit
25820cf8
authored
Nov 26, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// AI
parent
2ed3887d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
YHAutoTextView.swift
galaxy/galaxy/Classes/Base/V/YHAutoTextView.swift
+15
-1
YHAITextInputView.swift
...es/Modules/AI/AI-Dialogue(AI对话)/V/YHAITextInputView.swift
+8
-9
No files found.
galaxy/galaxy/Classes/Base/V/YHAutoTextView.swift
View file @
25820cf8
...
...
@@ -27,12 +27,13 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
let
label
=
UILabel
()
label
.
translatesAutoresizingMaskIntoConstraints
=
false
label
.
textColor
=
UIColor
.
lightGray
label
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
1
5
)
label
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
1
4
)
return
label
}()
override
init
(
frame
:
CGRect
,
textContainer
:
NSTextContainer
?)
{
super
.
init
(
frame
:
frame
,
textContainer
:
textContainer
)
self
.
font
=
.
PFSC_R
(
ofSize
:
14
)
delegate
=
self
isScrollEnabled
=
false
// 禁止滚动
self
.
addSubview
(
placeholderLabel
)
...
...
@@ -57,7 +58,20 @@ class YHAutoTextView: UITextView, UITextViewDelegate {
override
var
intrinsicContentSize
:
CGSize
{
// 计算内容的尺寸
// var height = self.getHeight(text: self.text, font: self.font!, width: frame.width)
// if height < 20.0 {
// height = 20.0
// }
// // 加上textView周边的缝隙
// height += 15.0
let
size
=
sizeThatFits
(
CGSize
(
width
:
frame
.
width
,
height
:
.
greatestFiniteMagnitude
))
return
CGSize
(
width
:
size
.
width
,
height
:
size
.
height
)
}
func
getHeight
(
text
:
String
,
font
:
UIFont
,
width
:
CGFloat
)
->
CGFloat
{
let
size
=
CGSize
.
init
(
width
:
width
,
height
:
CGFloat
(
MAXFLOAT
))
let
dic
=
[
NSAttributedString
.
Key
.
font
:
font
]
let
strSize
=
text
.
boundingRect
(
with
:
size
,
options
:
[
.
usesLineFragmentOrigin
],
attributes
:
dic
,
context
:
nil
)
.
size
return
CGSizeMake
(
strSize
.
width
,
ceil
(
strSize
.
height
))
.
height
}
}
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/V/YHAITextInputView.swift
View file @
25820cf8
...
...
@@ -33,6 +33,7 @@ class YHAITextInputView: UIView {
let
btn
=
UIButton
(
type
:
.
custom
)
btn
.
backgroundColor
=
.
red
btn
.
addTarget
(
self
,
action
:
#selector(
didSendButtonClicked
)
,
for
:
.
touchUpInside
)
btn
.
YH_clickEdgeInsets
=
UIEdgeInsets
(
top
:
20
,
left
:
20
,
bottom
:
20
,
right
:
20
)
return
btn
}()
...
...
@@ -88,21 +89,19 @@ class YHAITextInputView: UIView {
}
sendBtn
.
snp
.
makeConstraints
{
make
in
make
.
width
.
equalTo
(
50
)
make
.
height
.
equalTo
(
50
)
make
.
width
.
equalTo
(
24
)
make
.
height
.
equalTo
(
24
)
make
.
right
.
equalTo
(
-
16
)
make
.
bottom
.
equalTo
(
-
1
3
)
make
.
bottom
.
equalTo
(
-
1
0
)
}
textView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
16
)
make
.
top
.
equalTo
(
16
)
make
.
bottom
.
equalTo
(
-
16
)
make
.
right
.
equalTo
(
sendBtn
.
snp
.
left
)
.
offset
(
-
10
)
make
.
left
.
equalTo
(
5
)
make
.
top
.
equalTo
(
4
)
make
.
bottom
.
equalTo
(
-
4
)
make
.
right
.
equalTo
(
sendBtn
.
snp
.
left
)
.
offset
(
-
5
)
}
addKeyBoardNotify
()
}
@objc
func
handleKeyboardNotification
(
_
notification
:
Notification
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment