Welcome to the API documentation for the GrowingTextView library. Below you will find detailed information about the available classes, methods, and properties.
Installation
To install the GrowingTextView library, follow these steps:
- In your terminal, navigate to the root directory of your project.
- Run the following command to install the library using Cocoapods:
pod 'GrowingTextView'
- Open your project in Xcode and import the library:
#import <GrowingTextView/GrowingTextView.h>
Usage
To use the GrowingTextView library in your project, follow these steps:
- Create an instance of GrowingTextView:
- Customize the appearance and behavior of the textView, if desired:
- Set the font:
textView.font = [UIFont systemFontOfSize:14.0];
- Set the placeholder text:
textView.placeholder = @"Enter text here";
- Set the font:
- Implement the GrowingTextViewDelegate methods to handle events:
- Implement the textView:didChangeHeight: delegate method to be notified when the height of the textView changes:
- (void)textView:(UITextView *)textView didChangeHeight:(CGFloat)height { // Handle height change }
- Implement the textView:didChangeHeight: delegate method to be notified when the height of the textView changes:
GrowingTextView *textView = [[GrowingTextView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
[self.view addSubview:textView];
Classes
GrowingTextView
The GrowingTextView class is a subclass of UITextView and provides a text view that automatically adjusts its height based on the content. It also includes features like placeholder text and delegate methods for handling text changes.
Properties
@property (nonatomic, weak) id<GrowingTextViewDelegate> delegate
- The delegate object that receives messages from the GrowingTextView.
@property (nonatomic, copy) NSString *placeholder
- The placeholder text to be displayed when the text view is empty.
@property (nonatomic, strong) UIFont *font
- The font used for displaying the text in the text view.
Methods
- (void)reloadInputViews
- Reloads the input views, including the keyboard, associated with the GrowingTextView.
- (void)scrollRangeToVisible:(NSRange)range
- Scrolls the text view so that the specified range of text is visible.
Protocols
GrowingTextViewDelegate
The GrowingTextViewDelegate protocol defines the methods that a delegate of a GrowingTextView should implement to be notified of important events, such as changes in the text view’s height or text content.
Methods
- (void)textView:(UITextView *)textView didChangeHeight:(CGFloat)height
- Notifies the delegate that the height of the GrowingTextView has changed.
- (void)textViewDidChange:(UITextView *)textView
- Notifies the delegate that the text in the GrowingTextView has changed.
Congratulations! You have successfully installed the GrowingTextView library and learned how to use it in your project. Feel free to explore the available classes, properties, and methods to further enhance the functionality of your text views.