美文网首页
textField.placeholder颜色的修改

textField.placeholder颜色的修改

作者: 奋斗的小老鼠 | 来源:发表于2017-03-20 13:41 被阅读26次

    textField.placeholder颜色的修改方式,为自己做一个记录,希望能帮到有需要的朋友。

    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(15, 128, Kwidth - 30, 21)];
        //    textField.text = @"输入你想要直播的标题";
        textField.delegate = self;
        textField.placeholder = @"输入你想要直播的内容";
        
        //更改placeholder 的颜色
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        dict[NSForegroundColorAttributeName] = [UIColor whiteColor];
        NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:textField.placeholder attributes:dict];
        [textField setAttributedPlaceholder:attribute];
        
        textField.textAlignment = NSTextAlignmentCenter;
        textField.textColor = [UIColor whiteColor];
        [view addSubview:textField];
    

    相关文章

      网友评论

          本文标题:textField.placeholder颜色的修改

          本文链接:https://www.haomeiwen.com/subject/npnbnttx.html