• IOS:UITextField设置背景提示字,左侧图标的方法


       //搜索框背景

            _searchTextField.backgroundColor=kColorFromRGB((0x456C91));

            _searchTextField.placeholder=@"请输入搜索内容";

       //背景提示字的颜色,字体

            [_searchTextField setValue:kColorFromRGB((0x7D98B2)) forKeyPath:@"_placeholderLabel.textColor"];

            [_searchTextField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];

        //搜索图

            UIImageView *searchP=[[UIImageView alloc]initWithFrame:CGRectMake(2, 6, 33, 33)];

            searchP.image=[UIImage imageNamed:@"searchT"];

            _searchTextField.leftView=searchP;

            _searchTextField.leftViewMode=UITextFieldViewModeAlways;

            _searchTextField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;

    /////==========================

    注意:上面的提示字的颜色设置在13版本系统后会报错,APP用到了会闪退,大家可以搜搜相关内容

  • 相关阅读:
    [Objective-c 基础
    [Objective-c 基础
    [Objective-c 基础
    [Objective-c 基础
    [Objective-c 基础
    [Objective-c 基础
    [Objective-c 基础
    [Objective-c 基础
    [Objective-c 基础
    39. Combination Sum(dfs)
  • 原文地址:https://www.cnblogs.com/kc1995/p/13500911.html
Copyright © 2020-2023  润新知