iOS开发修改UITextField的placeholder的颜色字体大小等

xiaoxiao2021-02-28  129

贴上代码

UITextField *textField = [UITextField new]; NSString *placeHolderStr = @"我是placeholder"; textField.placeholder = placeHolderStr; NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:placeHolderStr]; [placeholder addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, placeHolderStr.length)]; [placeholder addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:16] range:NSMakeRange(0, placeHolderStr.length)]; textField.attributedPlaceholder = placeholder;
转载请注明原文地址: https://www.6miu.com/read-29471.html

最新回复(0)