IOS UI 학습 튜 토리 얼 설정 UITextField 각종 속성
7088 단어 IOSUIUITextField
// textfield
UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)];
// ,
text.borderStyle = UITextBorderStyleRoundedRect;
typedef enum {
UITextBorderStyleNone,
UITextBorderStyleLine,
UITextBorderStyleBezel,
UITextBorderStyleRoundedRect
} UITextBorderStyle;
// ,
text.backgroundColor = [UIColor whiteColor];
//
text.background = [UIImage imageNamed:@"dd.png"];
//
text.disabledBackground = [UIImage imageNamed:@"cc.png"];
// , password
text.placeholder = @"password";
//
text.font = [UIFont fontWithName:@"Arial" size:20.0f];
//
text.textColor = [UIColor redColor];
// , ,
text.clearButtonMode = UITextFieldViewModeAlways;
typedef enum {
UITextFieldViewModeNever,
UITextFieldViewModeWhileEditing,
UITextFieldViewModeUnlessEditing,
UITextFieldViewModeAlways
} UITextFieldViewMode;
//
text.text = @" ";
//
text.secureTextEntry = YES;
//
text.autocorrectionType = UITextAutocorrectionTypeNo;
typedef enum {
UITextAutocorrectionTypeDefault,
UITextAutocorrectionTypeNo,
UITextAutocorrectionTypeYes,
} UITextAutocorrectionType;
//
text.clearsOnBeginEditing = YES;
//
text.textAlignment = UITextAlignmentLeft;
// UITextField UIControl, contentVerticalAlignment
text.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
// YES . ,
textFied.adjustsFontSizeToFitWidth = YES;
//
text.minimumFontSize = 20;
//
text.keyboardType = UIKeyboardTypeNumberPad;
typedef enum {
UIKeyboardTypeDefault, ,
UIKeyboardTypeASCIICapable, ASCII
UIKeyboardTypeNumbersAndPunctuation, , +*#
UIKeyboardTypeURL, URL , .com URL
UIKeyboardTypeNumberPad,
UIKeyboardTypePhonePad,
UIKeyboardTypeNamePhonePad, ,
UIKeyboardTypeEmailAddress,
UIKeyboardTypeDecimalPad,
UIKeyboardTypeTwitter, , @、#
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable,
} UIKeyboardType;
//
text.autocapitalizationType = UITextAutocapitalizationTypeNone;
typedef enum {
UITextAutocapitalizationTypeNone,
UITextAutocapitalizationTypeWords,
UITextAutocapitalizationTypeSentences,
UITextAutocapitalizationTypeAllCharacters,
} UITextAutocapitalizationType;
//return
text.returnKeyType =UIReturnKeyDone;
typedef enum {
UIReturnKeyDefault, , Return
UIReturnKeyGo, Go
UIReturnKeyGoogle,
Google ,
UIReturnKeyJoin,
Join
UIReturnKeyNext,
Next
UIReturnKeyRoute,
Route
UIReturnKeySearch,
Search
UIReturnKeySend,
Send
UIReturnKeyYahoo,
Yahoo
UIReturnKeyYahoo,
Yahoo
UIReturnKeyEmergencyCall,
} UIReturnKeyType;
//
textView.keyboardAppearance=UIKeyboardAppearanceDefault;
typedef enum {
UIKeyboardAppearanceDefault, ,
UIKeyboardAppearanceAlert,
} UIReturnKeyType;
//
text.delegate = self;
// textfield
[self.window addSubview:text];
//
UIImageView *image=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"right.png"]];
text.rightView=image;
text.rightViewMode = UITextFieldViewModeAlways;
typedef enum {
UITextFieldViewModeNever,
UITextFieldViewModeWhileEditing,
UITextFieldViewModeUnlessEditing,
UITextFieldViewModeAlways
} UITextFieldViewMode;
// return becomeFirstResponder
UITextFieldDelegate
text.delegate = self; text , UITextFieldDelegate UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[text resignFirstResponder]; // [receiver resignFirstResponder] receiver
return YES;
}
UITextField , UITextField , , 。 CGRect , 。 。
C textRectForBounds: //
C drawTextInRect:
// . super , , super .
C placeholderRectForBounds:
//
C drawPlaceholderInRect:
// . super , , super .
C borderRectForBounds:
//
C editingRectForBounds:
//
C clearButtonRectForBounds:
// clearButton , size button
C leftViewRectForBounds:
C rightViewRectForBounds:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
// BOOL ,
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
// , first responder
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
// BOOL , , , first responder
// , NO
// ,
return NO;
}
- (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
// , , 。
//
// , , 。
// NO
// NSRange , ,
return YES;
}
- (BOOL)textFieldShouldClear:(UITextField *)textField{
// BOOL
//
return YES;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
// BOOL ,
// resignFirstResponder , , [textField resignFirstResponder];
// resign
return YES;
}
이상 은 본 고의 모든 내용 이 므 로 여러분 들 이 IOS 프로 그래 밍 을 배 우 는 데 도움 이 되 기 를 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
IOS에서 ReplayKit 및 RTC 사용 방법응용된 소리와 아나운서의 소리를 포함한다.이 두 가지 수요를 감안하여 우리는 스크린 공유를 하는 생방송에 필요한 미디어 흐름을 간단하게 분석할 수 있다. 만약 우리가 Audio App과 Audio Mic를 두 개의 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.