UITextField에 대한 자리 표시 자 텍스트가 있는데 한 부분은 나머지 자리 표시 자 텍스트보다 글꼴 크기가 더 커야합니다. attributePlaceHolder 속성을 사용하여이 작업을 수행 할 수 있습니까? 속성 문자열을 통해 추가하는 글꼴 크기를 존중하지 않는 것 같습니다.
현재 하나의 글꼴 크기를 시도하고 있지만 작동하지 않는 것 같습니다.
NSAttributedString *placeholder = [[NSAttributedString alloc] initWithString:placeholderText
attributes:@{NSFontAttributeName : [UIFont fontWithName:textField.font.fontName size:8.0]}];
textField.attributedPlaceholder = placeholder;
현재 나는 이것이 가능하다고 생각하지 않습니다 attributedPlaceHolder
. 그러나 setAttributedText
다음을 수행하여 가능합니다.
UIFont *futuraFont = [UIFont fontWithName:@"Futura" size:18.0];
NSDictionary *futuraDictionary = [NSDictionary dictionaryWithObject: futuraFont forKey:NSFontAttributeName];
NSMutableAttributedString *fAttrString = [[NSMutableAttributedString alloc] initWithString:title attributes: futuraDictionary];
UIFont *menloFont = [UIFont fontWithName:@"Menlo" size:12.0];
NSDictionary *menloDictionary = [NSDictionary dictionaryWithObject:menloFont forKey:NSFontAttributeName];
NSMutableAttributedString *mAttrString = [[NSMutableAttributedString alloc]initWithString:title2 attributes:menloDictionary];
[mAttrString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:(NSMakeRange(0, [title2 length]))];
[fAttrString appendAttributedString:mAttrString];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 200, 320, 100)];
[textField setAllowsEditingTextAttributes:YES];
[textField setAttributedText:fAttrString];
[self.view addSubview:textField];
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다