UITextField的leftView



这种UITextField实现效果如下:

    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 45, 21)];    
    lbl.backgroundColor = [UIColor clearColor];
    lbl.textColor = [UIColor lightGrayColor];
    lbl.text = @"Start:";

    UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(50, 100, 150, 31)];
    tf.borderStyle = UITextBorderStyleRoundedRect;
    tf.leftViewMode = UITextFieldViewModeAlways;    
    tf.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    tf.leftView = lbl;

你可能感兴趣的:(UITextField的leftView)