Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tichise/formsheettextview
FormSheetTextView is a FormSheet style UITextView.
https://github.com/tichise/formsheettextview
cocoapods objective-c objectivec swift swift3
Last synced: 3 months ago
JSON representation
FormSheetTextView is a FormSheet style UITextView.
- Host: GitHub
- URL: https://github.com/tichise/formsheettextview
- Owner: tichise
- License: mit
- Created: 2017-08-21T09:31:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-22T12:48:21.000Z (6 months ago)
- Last Synced: 2024-10-01T16:49:59.923Z (4 months ago)
- Topics: cocoapods, objective-c, objectivec, swift, swift3
- Language: Swift
- Homepage:
- Size: 65.4 KB
- Stars: 5
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
### FormSheetTextView ![CocoaPods Version](https://img.shields.io/cocoapods/v/FormSheetTextView.svg?style=flat) ![Platform](https://img.shields.io/cocoapods/p/PageSheetForm.svg?style=flat) ![License](https://img.shields.io/cocoapods/l/PageSheetForm.svg?style=flat)
FormSheetTextView is a FormSheet style UITextView.
### Image
#### iPhone
#### iPhone Plus
#### iPad
### Examples
#### Swift
```html
import FormSheetTextViewlet initialText = self.baseTextView?.text
guard let formSheetTextViewController = FormSheetTextViewController.instantiate() else {
return
}formSheetTextViewController.set(initialText: initialText)
formSheetTextViewController.set(titleText: "Title")
formSheetTextViewController.set(cancelButtonText: "Cancel")
formSheetTextViewController.set(isInitialPositionHead: false)
// formSheetTextViewController.set(titleSize: 20) // default 15
// formSheetTextViewController.set(buttonSize: 20) // default 15formSheetTextViewController.set(isPreview: true)
formSheetTextViewController.set(previewPageTitle: "Preview")
formSheetTextViewController.set(sendButtonText: "Send")
formSheetTextViewController.completionHandler = { sendText in
if sendText.count > 20 {
let alertController:UIAlertController = UIAlertController(title:nil, message: "The number of characters exceeds the upper limit. Please enter within 20 characters.", preferredStyle: UIAlertController.Style.alert)
let cancelAction:UIAlertAction = UIAlertAction(title: "Close", style: UIAlertAction.Style.cancel, handler:{ (action:UIAlertAction!) -> Void in
})
alertController.addAction(cancelAction)
formSheetTextViewController.present(alertController, animated: true, completion: nil)
return
}
if sendText.count == 0 {
let alertController:UIAlertController = UIAlertController(title:nil, message: "It is not input. Please enter.", preferredStyle: UIAlertController.Style.alert)
let cancelAction:UIAlertAction = UIAlertAction(title: "Close", style: UIAlertAction.Style.cancel, handler:{ (action:UIAlertAction!) -> Void in
})
alertController.addAction(cancelAction)
formSheetTextViewController.present(alertController, animated: true, completion: nil)
return
}
// success
self.baseTextView?.text = sendText
formSheetTextViewController.dismiss(animated: true, completion: nil)
};
let navigationController = UINavigationController(rootViewController: formSheetTextViewController)
navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
present(navigationController, animated: true, completion: nil)
```#### ObjectiveC
```
@import FormSheetTextView;__weak FormSheetTextViewController *formSheetTextViewController = [FormSheetTextViewController instantiate];
[formSheetTextViewController setWithInitialText:@"initial text"];
[formSheetTextViewController setWithTitleText:@"Title"];
[formSheetTextViewController setWithCancelButtonText:@"Cancel"];
[formSheetTextViewController setWithSendButtonText:@"Send"];
[formSheetTextViewController setCompletionHandler:^(NSString *sendText) {
if ([sendText length] > 20) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"The number of characters exceeds the upper limit. Please enter within 20 characters." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
[alertController addAction:cancelAction];
[formSheetTextViewController presentViewController:alertController animated:YES completion:nil];return;
}
if ([sendText length] == 0) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"It is not input. Please enter.." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
[alertController addAction:cancelAction];
[formSheetTextViewController presentViewController:alertController animated:YES completion:nil];
return;
}
[formSheetTextViewController dismissViewControllerAnimated:true completion:nil];
}];UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:formSheetTextViewController];
[navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentViewController:navigationController animated:true completion:nil];
```### Installation (CocoaPods)
`pod FormSheetTextView`