UILabel用法

/设置换行
UILabel*label;

//设置换行
label.lineBreakMode = UILineBreakModeWordWrap; 
label.numberOfLines = 0;

换行符还是\n
比如NSString * xstring=@"lineone\nlinetwo"

 记得要把label的高度设置的足够显示多行内容。

 

(void)LY_Display
{
    UILabel *LY_Label = [[UILabel alloc] initWithFrame:CGRectMake(60, 180, 60, 30)];
    [self.view addSubview:LY_Label];
    LY_Label.backgroundColor = [UIColor clearColor];
    LY_Label.text = @"密   码";
    LY_Label.font= [UIFont fontWithName:@"zapfino" size:(15.0f)]; //字体设置
   

    UITextField *LY_Text = [[UITextField alloc] initWithFrame:CGRectMake(143, 180, 80, 30) ];
    [self.view addSubview:LY_Text];
    LY_Text.backgroundColor = [UIColor whiteColor];
    [LY_Text setBorderStyle:UITextBorderStyleLine];             //边框设置
    LY_Text.placeholder = @"password";                          //默认显示的字
    LY_Text.font = [UIFont fontWithName:@"helvetica" size:12];  //字体和大小设置
    LY_Text.textColor = [UIColor redColor];                     //设置字体的颜色
    LY_Text.clearButtonMode = UITextFieldViewModeWhileEditing;  //清空功能x
    LY_Text.returnKeyType = UIReturnKeyDone;                    //键盘有done
    LY_Text.secureTextEntry = YES;                              //密码输入时
    LY_Text.delegate = self;                                    //托管
    
}
 

你可能感兴趣的:(UILabel)