Skip to content

Commit 1b2eed6

Browse files
author
Semen Osipov
committed
Add migration guide from HPGrowingTextView
Covers API parity, key differences, new features, and a side-by-side Obj-C → Swift code example. Made-with: Cursor
1 parent 1414e83 commit 1b2eed6

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,71 @@ textView.internalTextView.autocorrectionType = .no
134134
| `growingTextViewShouldReturn(_:)` | Return key tapped — return `true` to resign first responder |
135135
| `userDidPaste(images:)` | User pasted images from the pasteboard |
136136

137+
## Migrating from HPGrowingTextView
138+
139+
ARGrowingTextView preserves the same architectural approach (a `UIView` wrapping an internal `UITextView`) and keeps familiar API names, so migration is mostly mechanical.
140+
141+
### What stays the same
142+
143+
| HPGrowingTextView (Obj-C) | ARGrowingTextView (Swift) |
144+
|---|---|
145+
| `maxNumberOfLines` / `minNumberOfLines` | `maxNumberOfLines` / `minNumberOfLines` |
146+
| `maxHeight` / `minHeight` | `maxHeight` / `minHeight` |
147+
| `animateHeightChange` | `animateHeightChange` |
148+
| `animationDuration` | `animationDuration` |
149+
| `.internalTextView` | `.internalTextView` |
150+
| `text`, `font`, `textColor`, `textAlignment`, `selectedRange`, `editable`, `dataDetectorTypes`, `returnKeyType` | Same — proxied directly |
151+
| All `growingTextView…` delegate methods | Same names, Swift syntax |
152+
153+
### What changed
154+
155+
| Change | Details |
156+
|---|---|
157+
| **Language** | Objective-C → Swift 5.10+ |
158+
| **Min deployment** | iOS 4+ → iOS 13+ |
159+
| **Installation** | CocoaPods → Swift Package Manager |
160+
| **Layout** | Frame-based → Auto Layout (add as subview and pin with constraints) |
161+
| **Height animation callback** | `willChangeHeight:` was called *inside* the animation block. Now use `changeHeightWith:animationContext:` and call `animationContext.animate { … }` to synchronize your layout changes. |
162+
| **Delegate protocol** | `HPGrowingTextViewDelegate``ARGrowingTextViewDelegate` |
163+
164+
### What's new
165+
166+
- **Markdown** — live bold, italic, strikethrough, and underline rendering via `MarkdownTextStorage`
167+
- **Smart paste / copy** — RTF, HTML, and URL paste converted to Markdown; copy preserves formatting
168+
- **Style menu** — context menu actions (Bold, Italic, Underline, Strikethrough) on selected text
169+
- **Image paste**`userDidPaste(images:)` delegate callback
170+
- **Placeholder** — built-in placeholder label with customizable color
171+
- **Dynamic Type** — automatic font updates on `UIContentSizeCategory` changes
172+
173+
### Quick example
174+
175+
```diff
176+
- #import "HPGrowingTextView.h"
177+
+ import ARGrowingTextView
178+
179+
- HPGrowingTextView *textView = [[HPGrowingTextView alloc] initWithFrame:rect];
180+
- textView.minNumberOfLines = 1;
181+
- textView.maxNumberOfLines = 5;
182+
+ let textView = ARGrowingTextView()
183+
+ textView.minNumberOfLines = 1
184+
+ textView.maxNumberOfLines = 5
185+
186+
// Height animation
187+
- - (void)growingTextView:(HPGrowingTextView *)gTV willChangeHeight:(float)height {
188+
- [UIView animateWithDuration:0.1 animations:^{
189+
- // adjust layout
190+
- }];
191+
- }
192+
+ func growingTextView(_ growingTextView: ARGrowingTextView,
193+
+ changeHeightWith diff: CGFloat,
194+
+ animationContext: ARAnimationContext) {
195+
+ animationContext.animate {
196+
+ self.bottomConstraint.constant += diff
197+
+ self.view.layoutIfNeeded()
198+
+ }
199+
+ }
200+
```
201+
137202
## Acknowledgments
138203

139204
ARGrowingTextView is inspired by [HPGrowingTextView](https://github.com/HansPinckaers/GrowingTextView)

0 commit comments

Comments
 (0)