Four-Uitextview Usage summary of iOS development series

Source: Internet
Author: User

Initialize the input box and set the position and size uitextview *textview = [[Uitextview alloc] Initwithframe:cgrectmake (10, 10, 300, 180)];// Set Preset text Textview.text = @ "";//Set text font textview.font = [Uifont fontwithname:@ "Arial" size:16.5f];// Set text color Textview.textcolor = [Uicolor colorwithred:51/255.0f green:51/255.0f blue:51/255.0f alpha:1.0f];// Set text box background color textview.backgroundcolor = [Uicolor colorwithred:254/255.0f green:254/255.0f blue:254/255.0f alpha:1.0f];// Set text Alignment textview.textalignment = nstextalignmentleft;//iOS7 This alignment is in the following ways://enum {//Nstextalignmentleft = 0, left-aligned, default//Nstextalignmentcenter = 1, center-aligned//Nstextalignmentright = 2, right-justified//Nstextalignme ntjustified = 3, natural alignment at the last line of a paragraph//nstextalignmentnatural = 4, default alignment//} nstextalignment;//set automatic error correction mode TextView . Autocorrectiontype = uitextautocorrectiontypeno;//Automatic error correction methods are as follows://enum {//Uitextautocorrectiontypedefault, default Uitextautocorrectiontypeno, no automatic error correction//Uitextautocorrectiontypeyes,      Auto error correction//} uitextautocorrectiontype;//set automatic capitalization Textview.autocapitalizationtype = uitextautocapitalizationtypenone;/ /automatic capitalization is available in the following ways://enum {//Uitextautocapitalizationtypenone, not automatically capitalized//Uitextautocapitalizationtyp Ewords, capitalize the first letter of the word//uitextautocapitalizationtypesentences, capitalize the first letter of the sentence//Uitextautocapitalizationty Peallcharacters, all letters Uppercase//} uitextautocapitalizationtype;//set the keyboard style Textview.keyboardtype = uikeyboardtypedefault;//           There are several keyboard styles://enum {//Uikeyboardtypedefault, default keyboard, support for all characters//uikeyboardtypeasciicapable,                    ASCII-enabled default keyboard//uikeyboardtypenumbersandpunctuation, standard telephone keypad, +*# characters//Uikeyboardtypeurl support,               URL keyboard that supports only URL characters, supports. com buttons//uikeyboardtypenumberpad, numeric keypad//Uikeyboardtypephonepad, Telephone keypad//UIKEYBOARDTYPENAMEPHONEPAD, phone keypad for entering people's names//uikeyboardtypeemailaddress, e-mail Keyboard//UikeyboardtyPedecimalpad, digital keypad with digits and decimal point//Uikeyboardtypetwitter, optimized keypad for easy input @, #字符//Uikeyboardt Ypealphabet = uikeyboardtypeasciicapable,//} uikeyboardtype;//set return key style Textview.returnkeytype = The uireturnkeydefault;//return key has the following styles://enum {//Uireturnkeydefault, default, Gray button, labeled return//Uireturnke YGo, marked with Go Blue button//Uireturnkeygoogle, labeled with Google's blue button for search//Uireturnkeyjoin, marked with Jo In blue button//uireturnkeynext, blue button labeled next//Uireturnkeyroute, blue button labeled route//Uireturn Keysearch, blue button//uireturnkeysend labeled Search, blue button with Send//Uireturnkeyyahoo, marked with Yah OO blue button//Uireturnkeyyahoo, blue button labeled Yahoo//uireturnkeyemergencycall, Emergency call button//} Uireturnkeytype ;//Set Whether you can drag textview.scrollenabled = yes;//Set Proxy textview.delegate = self;//custom text Box Placeholdertip = [[UILabel alloc] Initw Ithframe:cgrectmake (+, +,];tip.te)XT = @ "Your opinion is the greatest motive force for our progress, thank you!" "; tip.font = [Uifont fontwithname:@" Arial "Size:16.5f];tip.backgroundcolor = [Uicolor clearcolor];tip.enabled = NO;// Custom text box word counts count = [[UILabel alloc] Initwithframe:cgrectmake (n, +, +)];count.text = @ "+"; count.textalignment = Nstextalignmentright;count.font = [Uifont fontwithname:@ "Arial" Size:15.0f];count.backgroundcolor = [UIColor clearcolor];count.enabled = no;//display text box and related controls [Self.view Addsubview:feedback]; [Self.view Addsubview:tip]; [Self.view addsubview:count];//Limit input text length-(BOOL) TextView: (Uitextview *) TextView Shouldchangetextinrange: (Nsrange)    Range Replacementtext: (NSString *) text{if (Range.location <) {return YES;    } else {return NO; }}//Custom text box placeholder-(void) Textviewdidchange: (Uitextview *) textview{count.text = [NSString stringwithformat:@ "%d"    , 240-feedback.text.length]; if (TextView.text.length = = 0) {Tip.text = @ "Your opinion is the greatest motive force of our progress, thank you!"    ";    } else {tip.text = @ ""; }}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.