Skip to content

Commit e3e06bc

Browse files
committed
Update examples
1 parent 380097b commit e3e06bc

2 files changed

Lines changed: 50 additions & 13 deletions

File tree

Example/Example (Shared)/ContentView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ struct ContentView: View {
7777
#endif
7878
ExampleSection("Customized textContentInset") {
7979
ResizingTextView(
80-
text: $text5,
81-
placeholder: ""
80+
text: $text5
8281
)
8382
#if os(macOS)
8483
.textContainerInset(CGSize(width: 40, height: 10))

README.md

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,69 @@ This is a SwiftUI resizing text view for iOS and macOS.
55
## Usage
66

77
```swift
8-
// Resizing automatically
9-
ResizingTextView(
10-
text: $text1,
11-
isScrollable: true,
12-
canHaveNewLineCharacters: true)
8+
// Self-sizing automatically (Default)
9+
ResizingTextView(text: $text1)
1310

14-
// Fixed-height, newline characters not allowed
11+
// Fixed height, scrollable, newline characters not allowed
1512
ResizingTextView(
1613
text: $text2,
1714
placeholder: "Placeholder",
1815
isScrollable: true,
19-
canHaveNewLineCharacters: false)
16+
canHaveNewLineCharacters: false
17+
)
18+
.frame(height: 80)
2019

2120
// Uneditable, selectable, color/font changed
2221
ResizingTextView(
2322
text: $text3,
24-
isEditable: false,
25-
font: .boldSystemFont(ofSize: 16),
26-
foregroundColor: .magenta)
23+
isEditable: false
24+
)
25+
.font(.boldSystemFont(ofSize: 16))
26+
.foregroundColor(.magenta)
2727

2828
// Uneditable, selectable, max 2 lines
2929
ResizingTextView(
3030
text: .constant("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."),
3131
isEditable: false,
32-
lineLimit: 2)
32+
lineLimit: 2
33+
)
34+
35+
// Uneditable, unselectable, max 2 lines
36+
ResizingTextView(
37+
text: .constant("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."),
38+
isEditable: false,
39+
isSelectable: false,
40+
lineLimit: 2
41+
)
42+
43+
// Selectable, uneditable, non greedy
44+
ResizingTextView(
45+
text: .constant("Lorem ipsum"),
46+
isEditable: false,
47+
hasGreedyWidth: false
48+
)
49+
.background(.yellow)
50+
51+
#if os(iOS)
52+
// No autocapitalization (iOS Only)
53+
ResizingTextView(
54+
text: $text4,
55+
placeholder: "Placeholder"
56+
)
57+
.autocapitalizationType(.none)
58+
#endif
59+
60+
// Customized textContentInset
61+
ResizingTextView(
62+
text: $text5,
63+
placeholder: ""
64+
)
65+
#if os(macOS)
66+
.textContainerInset(CGSize(width: 40, height: 10))
67+
#elseif os(iOS)
68+
.textContainerInset(UIEdgeInsets(top: 0, left: 40, bottom: 0, right: 40))
69+
#endif
70+
}
3371
```
3472

3573
## Demo

0 commit comments

Comments
 (0)