NSMutableParagraphStyle *style = [searchTF.defaultTextAttributes[NSParagraphStyleAttributeName] mutableCopy];
style.minimumLineHeight = searchTF.font.lineHeight - (searchTF.font.lineHeight - [UIFont systemFontOfSize:18].lineHeight) / 2.0;
searchTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请拨号或点击搜索姓名" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0.80 green:0.86 blue:0.85 alpha:1.00],NSFontAttributeName:[UIFont systemFontOfSize:18],NSParagraphStyleAttributeName:style}];
PlaceHolder设置垂直居中和颜色字体等
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 修改字体和颜色需要用到kvc: yourTextField.placeholder = @"username is...
- 原理是通过KVC来实现 //获取searchBar里面的TextField UITextField*searchF...
- 原理是通过KVC来实现 //获取searchBar里面的TextField UITextField*searchF...
- //通过runtime,我们发现UITextField有一个叫做_placeholderLabel的私有变量,下面...