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
84e574ef
Commit
84e574ef
authored
Aug 07, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added minimumTextHeight and adjusted TextView placeholder layout
parent
211e4b48
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
12 deletions
+17
-12
Sources/iOS/Editor.swift
+1
-0
Sources/iOS/TextField.swift
+2
-2
Sources/iOS/TextView.swift
+14
-10
No files found.
Sources/iOS/Editor.swift
View file @
84e574ef
...
...
@@ -223,6 +223,7 @@ private extension Editor {
let
rightPadding
=
inset
.
right
+
textView
.
textContainer
.
lineFragmentPadding
let
w
=
bounds
.
width
-
leftPadding
-
rightPadding
var
h
=
placeholderLabel
.
sizeThatFits
(
CGSize
(
width
:
w
,
height
:
.
greatestFiniteMagnitude
))
.
height
h
=
max
(
h
,
textView
.
minimumTextHeight
)
h
=
min
(
h
,
bounds
.
height
-
inset
.
top
-
inset
.
bottom
)
placeholderLabel
.
bounds
.
size
=
CGSize
(
width
:
w
,
height
:
h
)
...
...
Sources/iOS/TextField.swift
View file @
84e574ef
...
...
@@ -65,8 +65,8 @@ public protocol TextFieldDelegate: UITextFieldDelegate {
open
class
TextField
:
UITextField
{
/// Minimum TextField
height
private
var
minimumTextHeight
:
CGFloat
=
32
/// Minimum TextField
text height.
private
let
minimumTextHeight
:
CGFloat
=
32
/// Default size when using AutoLayout.
open
override
var
intrinsicContentSize
:
CGSize
{
...
...
Sources/iOS/TextView.swift
View file @
84e574ef
...
...
@@ -302,6 +302,9 @@ open class TextView: UITextView {
return
preferredMaxLayoutHeight
>
0
&&
isScrollEnabled
}
/// Minimum TextView text height.
internal
let
minimumTextHeight
:
CGFloat
=
32
open
override
var
intrinsicContentSize
:
CGSize
{
guard
isGrowEnabled
else
{
return
super
.
intrinsicContentSize
...
...
@@ -311,7 +314,8 @@ open class TextView: UITextView {
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
)
var
h
=
max
(
minimumTextHeight
,
placeholderH
)
+
insets
.
top
+
insets
.
bottom
h
=
max
(
h
,
contentSize
.
height
)
return
CGSize
(
width
:
UIView
.
noIntrinsicMetric
,
height
:
min
(
h
,
preferredMaxLayoutHeight
))
}
...
...
@@ -384,15 +388,15 @@ fileprivate extension TextView {
return
}
placeholderLabel
.
preferredMaxLayoutWidth
=
textContainer
.
size
.
width
-
textContainer
.
lineFragmentPadding
*
2
let
x
=
textContainerInset
.
lef
t
+
textContainer
.
lineFragmentPadding
let
y
=
textContainerInset
.
top
placeholderLabel
.
sizeToFit
()
placeholderLabel
.
frame
.
origin
.
x
=
x
placeholderLabel
.
frame
.
origin
.
y
=
y
placeholderLabel
.
frame
.
size
.
width
=
textContainer
.
size
.
width
-
textContainerInset
.
right
-
textContainer
.
lineFragmentPadding
let
insets
=
textContainerInsets
let
leftPadding
=
insets
.
left
+
textContainer
.
lineFragmentPadding
let
rightPadding
=
insets
.
righ
t
+
textContainer
.
lineFragmentPadding
let
w
=
bounds
.
width
-
leftPadding
-
rightPadding
var
h
=
placeholderLabel
.
sizeThatFits
(
CGSize
(
width
:
w
,
height
:
.
greatestFiniteMagnitude
))
.
height
h
=
max
(
h
,
minimumTextHeight
)
h
=
min
(
h
,
bounds
.
height
-
insets
.
top
-
insets
.
bottom
)
placeholderLabel
.
frame
=
CGRect
(
x
:
leftPadding
,
y
:
insets
.
top
,
width
:
w
,
height
:
h
)
}
}
...
...
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