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;

posted @ 2011-06-24 14:58  周宏伟  阅读(12940)  评论(1编辑  收藏  举报