美文网首页iOS DeveloperiOS开发记录
UITextField placeholder文字居左边界10

UITextField placeholder文字居左边界10

作者: 舒耀 | 来源:发表于2015-09-21 16:28 被阅读638次

    首先总体效果如下显示

    Paste_Image.png

    “手机号”、“验证码”居左10像素,背景为白色,文字为白色

    首先设置默认文字居左10像素显示

    UILabel *numLble        = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, phoneCodeField.frame.size.height)];
    numLble.text            = @"手机号";
    numLble.textColor       = [z_UI colorWithHexString:@"5b2f22"];
    numLble.textAlignment   = 1;
    numLble.font            = DEFAULT_FONT(14);
    phoneField.leftView     = numLble;
    phoneField.leftViewMode = UITextFieldViewModeAlways;
    

    leftView显示的位置,居左,
    leftViewMode
    typedef NS_ENUM(NSInteger, UITextFieldViewMode) {
    UITextFieldViewModeNever,
    UITextFieldViewModeWhileEditing,
    UITextFieldViewModeUnlessEditing,
    UITextFieldViewModeAlways
    };

    其次:设置背景白色,字体白色

    phoneCodeField.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.4f];
    phoneCodeField.textColor = [z_UI colorWithHexString:@"#ffffff"];
    

    colorWithAlphaComponent 设置背景的透明度这样就可以显示白色文字

    相关文章

      网友评论

        本文标题:UITextField placeholder文字居左边界10

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