• NSMutableAttributedString(转)


    NSMutableAttributedString计算高度的问题   
    
            _label_page2_1 = [[UILabel alloc] init];
            _label_page2_1.numberOfLines = 0;
             
            NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:@"addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30]"];
             
            [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(8, 2)];
            [attrString addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(8, 2)];
             
            [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(13, 2)];
            [attrString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(13, 2)];
             
             
            CGRect rect = [attrString boundingRectWithSize:CGSizeMake(320, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil];
             
            _label_page2_1.frame = CGRectMake(0 ,200, ceil(rect.size.width),ceil( rect.size.height));
            _label_page2_1.backgroundColor = [UIColor yellowColor];
            _label_page2_1.attributedText = attrString;
  • 相关阅读:
    poj2728 Desert King
    bzoj4289 Tax
    洛谷P4141消失之物
    Code Forces 698A Vacations
    Code Forces 543A Writing Code
    洛谷P1133 教主的花园
    poj3177 Redundant Paths
    bzoj1151 动物园
    bzoj1503 郁闷的出纳员
    bzoj1208 宠物收养所
  • 原文地址:https://www.cnblogs.com/ly1973/p/5431903.html
Copyright © 2020-2023  润新知