首页 > 其他 > 详细

drawRect方式画标签

时间:2015-09-06 18:10:45      阅读:183      评论:0      收藏:0      [点我收藏+]

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;

        }

drawRect方式画标签

原文:http://www.cnblogs.com/ranger-jlu/p/4786581.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!