Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
9fae5e1f
Commit
9fae5e1f
authored
Aug 07, 2018
by
Orkhan Alikhanov
Committed by
OrkhanAlikhanov
Aug 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added preferredMaxLayoutHeight to TextView
parent
9cd30b33
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
10 deletions
+42
-10
Sources/iOS/TextView.swift
+41
-10
Sources/iOS/Toolbar.swift
+1
-0
No files found.
Sources/iOS/TextView.swift
View file @
9fae5e1f
...
@@ -263,6 +263,12 @@ open class TextView: UITextView {
...
@@ -263,6 +263,12 @@ open class TextView: UITextView {
layoutShape
()
layoutShape
()
layoutShadowPath
()
layoutShadowPath
()
layoutPlaceholderLabel
()
layoutPlaceholderLabel
()
guard
isGrowEnabled
else
{
return
}
invalidateIntrinsicContentSize
()
}
}
/**
/**
...
@@ -283,18 +289,43 @@ open class TextView: UITextView {
...
@@ -283,18 +289,43 @@ open class TextView: UITextView {
prepareRegularExpression
()
prepareRegularExpression
()
preparePlaceholderLabel
()
preparePlaceholderLabel
()
}
}
open
override
func
insertText
(
_
text
:
String
)
{
/// Maximum preffered layout height before scrolling.
fixTypingFont
()
open
var
preferredMaxLayoutHeight
:
CGFloat
=
0
{
super
.
insertText
(
text
)
didSet
{
fixTypingFont
()
invalidateIntrinsicContentSize
()
}
}
}
open
override
func
paste
(
_
sender
:
Any
?)
{
fixTypingFont
()
/// A property indicating if textView allowed to grow.
super
.
paste
(
sender
)
private
var
isGrowEnabled
:
Bool
{
fixTypingFont
()
return
preferredMaxLayoutHeight
>
0
&&
isScrollEnabled
}
open
override
var
intrinsicContentSize
:
CGSize
{
guard
isGrowEnabled
else
{
return
super
.
intrinsicContentSize
}
}
let
insets
=
textContainerInsets
let
w
=
bounds
.
width
-
insets
.
left
-
insets
.
right
-
2
*
textContainer
.
lineFragmentPadding
let
placeholderH
=
placeholderLabel
.
sizeThatFits
(
CGSize
(
width
:
w
,
height
:
.
greatestFiniteMagnitude
))
.
height
let
h
=
max
(
contentSize
.
height
,
placeholderH
+
insets
.
top
+
insets
.
bottom
)
return
CGSize
(
width
:
UIView
.
noIntrinsicMetric
,
height
:
min
(
h
,
preferredMaxLayoutHeight
))
}
open
override
func
insertText
(
_
text
:
String
)
{
fixTypingFont
()
super
.
insertText
(
text
)
fixTypingFont
()
}
open
override
func
paste
(
_
sender
:
Any
?)
{
fixTypingFont
()
super
.
paste
(
sender
)
fixTypingFont
()
}
}
}
fileprivate
extension
TextView
{
fileprivate
extension
TextView
{
...
...
Sources/iOS/Toolbar.swift
View file @
9fae5e1f
...
@@ -129,6 +129,7 @@ open class Toolbar: Bar {
...
@@ -129,6 +129,7 @@ open class Toolbar: Bar {
prepareDetailLabel
()
prepareDetailLabel
()
}
}
/// A reference to titleLabel.textAlignment observation.
private
var
titleLabelTextAlignmentObserver
:
NSKeyValueObservation
!
private
var
titleLabelTextAlignmentObserver
:
NSKeyValueObservation
!
}
}
...
...
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