Uitextfield *textfield = [[Uitextfield alloc] init];// initialization
textfield.userinteractionenabled = yes;// is available
Textfield.text = @ "Uitextfield"; text
Textfield.delegate = self; Agent
Textfield.frame = CGRectMake (100, 100, 100, 40); size and position
Textfield.textcolor = [uicolor redcolor];// Font Color
Textfield.placeholder = @ "Uitextfield";// prompt character
[TextField Setborderstyle:uitextborderstyleroundedrect]; outer box type Uitextborderstyleroundedrect enumeration type
Textfield.securetextentry = YES; Password Box
Textfield.clearbuttonmode = uitextfieldviewmodewhileediting; edit will show a change X
Uiimageview *imgv=[[uiimageview alloc] initwithimage:[uiimage imagenamed:@ "Right.png"];
TEXTFIELD.RIGHTVIEW=IMGV;
Textfield.rightviewmode = Uitextfieldviewmodealways; add picture to right
Textfield.font = [Uifont systemfontofsize:14.0f];// the size of the text
Textfield.font = [Uifont boldsystemfontofsize:14.0f];// text Bold
Textfield.autocapitalizationtype = Uitextautocapitalizationtypenone; whether the initial letter is automatically capitalized
textfield.clearsonbeginediting = YES; edit it again and empty it .
Textfield.adjustsfontsizetofitwidth = YES; When set to YES , the text automatically shrinks to fit the text window size . The default is to keep the original size , while the long text scrolls
Textfield.minimumfontsize = 20; set the minimum font size for auto-shrink display
Textfield.keyboardtype = Uikeyboardtypenumberpad; Set the keyboard style
Textfield.backgroundcolor = [uicolor graycolor];// background color
Placeholder Color
First Kind
Uicolor *color = [Uicolor Whitecolor];
Textfield.attributedplaceholder = [[Nsattributedstring alloc] initwithstring:@ " username " attributes:@{ Nsforegroundcolorattributename:color}];
The second Kind
[TextField setvalue:[uicolor Whitecolor] forkeypath:@ "_placeholderlabel.textcolor"];//_placeholderlabel.textcolor This can't be changed .
Textfield.returnkeytype =uireturnkeydone; Return key becomes what key
Center text up or down
Textfield.contentverticalalignment = Uicontrolcontentverticalalignmentcenter;
Center text around
Textfield.textalignment = Nstextalignmentcenter;
Textfield.keyboardappearance=uikeyboardappearancedefault; Keyboard Appearance
Uitextfield the distance to the left
CGRect frame = [TextField frame];
Frame.size.width = 15;
UIView *leftview = [[UIView alloc] initwithframe:frame];
Textfield.leftviewmode = Uitextfieldviewmodealways; left margin is 15pix
Textfield.leftview = Leftview;
[TextField becomefirstresponder];// becomes the first responder
[Self.view Addsubview:textfield];
This article is from the "11204872" blog, please be sure to keep this source http://11214872.blog.51cto.com/11204872/1754517
Basic usage of IOS Uitextfield