UIlable 适应字体大小

来源:互联网 发布:浴火银河2修改数据 编辑:程序博客网 时间:2024/06/14 17:01
UILabel *shopAddressLabel = [[UILabel alloc]init]; //]WithFrame:CGRectMake(70, 90, SCREEN_WIDTH-80,LABEL_HEIGHT_30)];
    shopAddressLabel.font = [UIFont systemFontOfSize:[kFontSize12 floatValue]];
    NSString *strShopAddress  = @"上海市杨浦区等等路16号";
    [shopAddressLabel setNumberOfLines:0];
    shopAddressLabel.lineBreakMode = UILineBreakModeWordWrap;
    CGSize size = CGSizeMake(SCREEN_WIDTH-80,LABEL_HEIGHT_30);
    CGSize labelsize = [strShopAddress sizeWithFont:shopAddressLabel.font constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
    [shopAddressLabel setFrame:CGRectMake(70,90, labelsize.width, labelsize.height)];
    [shopAddressLabel setText:strShopAddress];
    [shopAddressLabel setTextColor:RGB(160, 160, 160, 1)];
    [shopInfoView addSubview:shopAddressLabel];
0 0
原创粉丝点击