@@ -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
1512ResizingTextView (
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
2221ResizingTextView (
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
2929ResizingTextView (
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