UILabel

     UILabel *labTest = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
    //设置字体大小
    labTest.font = [UIFont systemFontOfSize:14.0];
    UIFont *font = [UIFont fontWithName:@"Helvetica" size:15.0];  
    [labTest setFont:font];
    labTest.backgroundColor = [UIColor clearColor]; //清空背景色
    labTest.textColor = [UIColor blueColor]; //设置字体颜色
    labTest.textAlignment = UITextAlignmentRight; //设置对齐方式
    labTest.adjustsFontSizeToFitWidth = YES; //设置字体大小是否适应label宽度
    labTest.highlighted = YES; //设置是否是高亮
    labTest.highlightedTextColor = [UIColor whiteColor];  //高亮颜色
    labTest.shadowColor = [UIColor grayColor]; //设置阴影颜色
    labTest.shadowOffset = CGSizeMake(0.5, 0.5); //阴影偏移量    
    labTest.userInteractionEnabled = YES; //是否能和用户交互
    labTest.enabled = YES; //文字是否可变
    labTest.lineBreakMode = UILineBreakModeHeadTruncation; //文字过长时的显示方式
    [labTest setNumberOfLines:0];  //设置行数
    //自适应大小
    NSString *strText = @"啊啊啊啊啊啊啊啊啊了啦啦啦啦啦啦哦哦哦哦哦哦哦";  
    CGSize sizeTest = [strText sizeWithFont:font constrainedToSize:CGSizeMake(20.0f, 150.0f) lineBreakMode:UILineBreakModeWordWrap];  
    CGRect rect = labTest.frame;  
    rect.size = sizeTest;  
    [labTest setFrame:rect];  
    [labTest setText:strText]; 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值