FormSheetTextView
FormSheetTextView is a FormSheet style UITextView.
Image
iPhone
iPhone Plus
iPad
Examples
Swift
import FormSheetTextView
let 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 15
formSheetTextViewController.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