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;
}