UITextfield
사용자가 mac의 기본 응용 프로그램과 같은 테두리 강조 표시를 클릭하면 UIColor
은 애니메이션처럼 파란색으로 표시됩니다. 나는 iOS에서 새롭다. 도와주세요 . 미리 감사드립니다.Objective c의 UITextField 테두리
-9
A
답변
0
UITextField
의 레이어 속성을 사용하여 테두리를 만듭니다.
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.layer.borderColor = [UIColor colorWithRed:151.0/255.0f green:193.0/255.0f blue:252.0/255.0f alpha:1.0f].CGColor;
textField.layer.borderWidth = 3.0f;
textField.layer.cornerRadius = 7.0f;
[self.view addSubview:textField];
변경 borderWidth
와 맥 애플리케이션 텍스트 필드 등보다 정확하고 욕망 값 cornerRadius
값.
0
귀하의 TextField 대리인 방법 : 아래 코드를 입력하십시오.
- (void)textFieldDidBeginEditing:(UITextField *)textField;
{
_txtF.layer.borderColor= [UIColor blueColor].CGColor;
_txtF.layer.borderWidth = 1.0f;
_txtF.alpha = 0.0;
//somewhere here should be the [someView addSubview:tmp];
//and after that should go the [someView addSubview:yourTextFieldView];
//somewhere later in your code, when you need the animation to happen
[UIView animateWithDuration:0.1 animations:^{
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:_txtF.bounds];
_txtF.layer.masksToBounds = NO;
_txtF.layer.shadowColor = [UIColor blueColor].CGColor;
_txtF.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
_txtF.layer.shadowOpacity = 0.5f;
_txtF.layer.shadowPath = shadowPath.CGPath;
_txtF.alpha = 1.0;
_txtF.layer.cornerRadius = 4.0;
}];
}
귀하의 출력은 다음과 같습니다이 들어
0
당신이 위임
1.
- (void) textFieldDidBeginEditing:(UITextField *)textField {
if (textField == yourtextField) {
yourTextField.layer.borderColor = [[UIColor blueColor] CGColor];
yourTextField.layer.borderWidth = 1.0;
}
}
2.
에게 UITextField에 구현해야당신이 다음 IOS에서 대표에 대해 공부하고 이후
그것은 당신이 달성하려고하는 무엇
당신에게 도움이 될 것입니다 희망이 코드를 사용 위임에 대해 모른다면? 당신은 무엇을 시도 했습니까 ... – Miknash
이 사이트는 기본적인 것을 배울 수 없습니다. 인터넷에서 검색하고, 방법을 배우고, 자신을 시험해보십시오. 그리고 시도 할 때 문제가 발생하면 여기에서 질문하고 시도한 것을 보여주십시오. google의 단지 5 초는 나에게 이것을 준다 : https://coderwall.com/p/hsrecw/add-a-border-to-any-uiview – CRDave
나의 대답을 점검해라. 텍스트 필드 테두리 색상을 애니메이션으로 변경할 수 있습니다. –