zoukankan      html  css  js  c++  java
  • drawRect方式画标签

    if ([_info[@"cashBack"] floatValue] > 0) {

                

                y += 10.0;

                

                // 离店返金额说明

                UILabel *cashBackLabel = [TRIPLabelFactory createLabelWithText:[[NSString stringWithFormat:@"¥%0.2f",[_info[@"cashBack"] floatValue]/100.0] hotelPriceFormat]

                                                                         color:LABEL_RED

                                                                      fontSize:10

                                                                    labelStyle:LabelStyleSolid];

                CGSize labelTextSize = [cashBackLabel.text calculateSizeWithFont:cashBackLabel.font];

                text = [[NSString stringWithFormat:@"入住离店后再返¥%0.2f信用住酒店红包",[_info[@"cashBack"] floatValue]/100.0] hotelPriceFormat];

                size = [text calculateSizeWithFont:TEXT_FONT constrainedToSize:CGSizeMake([UIScreen mainScreen].bounds.size.width-15.0-5.0-cashBackLabel.width, 1000)];

                if (!onlyHeight) {

                    // 画标签

                    [LABEL_RED set];

                    CGContextRef context5 = UIGraphicsGetCurrentContext(); //设置上下文

                    CGContextSetLineWidth(context5, 1.0);

                    CGContextSetRGBStrokeColor(context5, 0.8, 0.1, 0.8, 1);

                    CGContextFillRect(context5, CGRectMake(x, y+(size.height-cashBackLabel.height)/2.0, cashBackLabel.width, cashBackLabel.height));

                    // 画标签文案

                    [[UIColor whiteColor] set];

                    [cashBackLabel.text drawInRect:CGRectMake(x+(cashBackLabel.width-labelTextSize.width)/2.0, y+(size.height-cashBackLabel.height)/2.0, cashBackLabel.width, cashBackLabel.height) withFont:cashBackLabel.font];

                    

                    [TITLE_TEXT_COLOR set];

                    [text drawInRect:CGRectMake(x+cashBackLabel.width+5.0, y, size.width, size.height) withFont:TEXT_FONT];

                }

                y += size.height;

            }

  • 相关阅读:
    解密时遇到 填充无效 无法被移除
    固态硬盘SSD,机械硬盘HDD,4K速度对比。
    onsubmit ajax return false 无效
    chrome flash
    ubuntu base make 未找到命令
    winrar 压缩命令
    查看耗时长,CPU 100% 的SQL
    【转】SQL Server日志文件过大 大日志文件清理方法 不分离数据库
    安装老版本redis .NET 客户端
    python2.0_day22_web聊天室二
  • 原文地址:https://www.cnblogs.com/ranger-jlu/p/4786581.html
Copyright © 2011-2022 走看看