textfield 的 placeholder 的属性怎么设置
发布网友
发布时间:2022-05-18 19:09
我来回答
共1个回答
热心网友
时间:2023-10-25 07:40
UITextField * textField = [[UITextField alloc]initWithFrame:CGRectMake(30, 150, 260, 30)];
textField.borderStyle = UITextBorderStyleRoundedRect;
NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc]initWithString:@"string"];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, attributedStr.length)];
textField.textAlignment = NSTextAlignmentCenter;
textField.attributedPlaceholder = attributedStr;
[self.view addSubview:textField];