zoukankan      html  css  js  c++  java
  • iOS UILanel 一些小实用

    UILabel *lab=[[UILabel alloc]initWithFrame:self.view.bounds];
    
    //合并
    lab.text=[NSString stringWithFormat:@"%@%@",@"coach: ","coache"];
    
    //圆形
    lab.layer.cornerRadius=num1.bounds.size.width/2;
    lab.layer.masksToBounds=YES;
    
    //换行,高度要足够才能换行
    lab.lineBreakMode = NSLineBreakByWordWrapping;
    lab.numberOfLines = 0;
    
    //边框
    lab.layer.borderColor = [UIColor colorWithRed:236.0f/255.0f green:235.0f/255.0f blue:240.0f/255.0f alpha:1].CGColor;//颜色
    lab.layer.borderWidth = 3.0f;//设置边框粗细
    lab.layer.masksToBounds = YES;
    
    lab.textAlignment =  NSTextAlignmentCenter;//居中
    lab.textAlignment = NSTextAlignmentLeft;//靠左
    lab.textAlignment = NSTextAlignmentRight;//靠右

    [lab setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18]]; 

    //根据文字的多少计算label宽度
    
    NSDictionary *labDic = @{NSFontAttributeName : [UIFont boldSystemFontOfSize:18]};
    CGSize size=[lab.text sizeWithAttributes:labDic]; 
    [lab setFrame:CGRectMake(
    0, 0, size.width, 20)];
  • 相关阅读:
    序列操作
    上帝造题的七分钟2 / 花神游历各国
    火柴排队
    pair(对组)用法
    线段树
    链上分治
    Rem与Px的转换
    css中单位px和em,rem的区别
    css网页自适应-1
    css网页自适应-2
  • 原文地址:https://www.cnblogs.com/sheer-code/p/10871429.html
Copyright © 2011-2022 走看看