Latest 1.4.2
Homepage https://github.com/tichise/FormSheetTextView
License MIT
Platforms ios 9.0, requires ARC

FormSheetTextView CocoaPods Version Platform License

FormSheetTextView is a FormSheet style UITextView.

Image

iPhone

FormSheetTextView
FormSheetTextView

iPhone Plus

FormSheetTextView

iPad

FormSheetTextView
FormSheetTextView

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

Latest podspec

{
    "name": "FormSheetTextView",
    "version": "1.4.2",
    "license": "MIT",
    "summary": "FormSheetTextView is a FormSheet style UITextView.",
    "homepage": "https://github.com/tichise/FormSheetTextView",
    "social_media_url": "http://twitter.com/tichise",
    "authors": "Takuya Ichise",
    "source": {
        "git": "https://github.com/tichise/FormSheetTextView.git",
        "tag": "1.4.2"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "Sources/*.swift",
    "requires_arc": true,
    "resource_bundles": {
        "FormSheetTextViewStoryboards": [
            "Storyboards/*.storyboard"
        ]
    }
}

Pin It on Pinterest

Share This