1 /**2 * 画分时图标签3 *4 * @param ctx 5 */
6 -(void)drawTimeLabel:(CGContextRef)ctx{7 NSMutableDictionary *attribute = [NSMutableDictionary new];8 NSMutableParagraphStyle *paragraphStyle =[[NSParagraphStyle defaultParagraphStyle] mutableCopy];9 paragraphStyle.alignment =NSTextAlignmentCenter;10 attribute[NSForegroundColorAttributeName] = [@"777777"hexColor];11 attribute[NSFontAttributeName] = [UIFont HeitiSCWithFontSize:11];12 attribute[NSParagraphStyleAttributeName] =paragraphStyle;13
14 //最大值
15 CGRect maxYRect =CGRectMake( self.width - MARGIN_LEFT_AND_RIGHT - 70*ScreenWidthRate , 3*ScreenHeightRate+MARGIN_LEFT_AND_RIGHT, 65*ScreenWidthRate , 15*ScreenHeightRate);16 paragraphStyle.alignment =NSTextAlignmentRight;17
18 [[NSString stringWithFormat:@"%.2f",_maxY] drawInRect:maxYRect withAttributes:attribute];19 CGRect maxPercentRect =CGRectMake( MARGIN_LEFT_AND_RIGHT+3*ScreenWidthRate , maxYRect.origin.y, maxYRect.size.width , maxYRect.size.height);20 paragraphStyle.alignment =NSTextAlignmentLeft;21
22 [[NSString stringWithFormat:@"%.2f%%",((_maxY-self.lastCloseValue.doubleValue)/self.lastCloseValue.doubleValue)*100] drawInRect:maxPercentRect withAttributes:attribute];23
24 //0
25 CGRect zeroRect =CGRectMake( maxYRect.origin.x , (self.height - BOTTOM_VIEW_HEIGHT - BOTTOM_CHART_HEIGHT - TWO_CHART_INTERVAL - MARGIN_LEFT_AND_RIGHT)/2+MARGIN_LEFT_AND_RIGHT - 7.5*ScreenHeightRate, maxYRect.size.width , maxYRect.size.height);26 paragraphStyle.alignment =NSTextAlignmentRight;27
28 [[NSString stringWithFormat:@"%.2f",(_maxY-_minY)/2+_minY] drawInRect:zeroRect withAttributes:attribute];29 paragraphStyle.alignment =NSTextAlignmentLeft;30
31 CGRect zeroPercentRect =CGRectMake( maxPercentRect.origin.x , zeroRect.origin.y, maxYRect.size.width , maxYRect.size.height);32 [@"0.00%"drawInRect:zeroPercentRect withAttributes:attribute];33
34 //最小值
35 CGRect minYRect =CGRectMake( maxYRect.origin.x , self.height- BOTTOM_VIEW_HEIGHT - BOTTOM_CHART_HEIGHT - TWO_CHART_INTERVAL-17*ScreenHeightRate, maxYRect.size.width , maxYRect.size.height);36 paragraphStyle.alignment =NSTextAlignmentRight;37
38 [[NSString stringWithFormat:@"%.2f",_minY] drawInRect:minYRect withAttributes:attribute];39
40 CGRect minPercentRect =CGRectMake( maxPercentRect.origin.x , minYRect.origin.y , maxYRect.size.width , maxYRect.size.height);41 paragraphStyle.alignment =NSTextAlignmentLeft;42
43 [[NSString stringWithFormat:@"%.2f%%",((_minY-self.lastCloseValue.doubleValue)/self.lastCloseValue.doubleValue)*100] drawInRect:minPercentRect withAttributes:attribute];44
45
46 //9:30
47 attribute[NSForegroundColorAttributeName] = [@"333333"hexColor];48 CGRect openRect = CGRectMake( MARGIN_LEFT_AND_RIGHT , self.height- BOTTOM_VIEW_HEIGHT - BOTTOM_CHART_HEIGHT - TWO_CHART_INTERVAL+2*ScreenHeightRate, 35*ScreenWidthRate , 15*ScreenHeightRate);49 [@"9:30"drawInRect:openRect withAttributes:attribute];50
51 //11:30
52 paragraphStyle.alignment =NSTextAlignmentCenter;53 CGRect middleRect = CGRectMake( (self.width - 2*MARGIN_LEFT_AND_RIGHT)/2-35*ScreenWidthRate/5 , self.height - BOTTOM_CHART_HEIGHT - BOTTOM_VIEW_HEIGHT- TWO_CHART_INTERVAL+2*ScreenHeightRate, 35*ScreenWidthRate , 15*ScreenHeightRate);54 [@"11:30"drawInRect:middleRect withAttributes:attribute];55
56 //15:00
57 paragraphStyle.alignment =NSTextAlignmentRight;58 attribute[NSParagraphStyleAttributeName] =paragraphStyle;59 CGRect closeRect = CGRectMake( self.width - MARGIN_LEFT_AND_RIGHT - 35*ScreenWidthRate , self.height - BOTTOM_CHART_HEIGHT- BOTTOM_VIEW_HEIGHT - TWO_CHART_INTERVAL+2*ScreenHeightRate, 35*ScreenWidthRate , 15*ScreenHeightRate);60 [@"15:00"drawInRect:closeRect withAttributes:attribute];61 //画矩形
62 CGContextSetRGBFillColor(ctx, 244/255.0, 244/255.0, 244/255.0, 1.0);63 //填充矩形
64 CGContextFillRect(ctx, CGRectMake(0, closeRect.origin.y+closeRect.size.height +5*ScreenHeightRate, Width, 5*ScreenHeightRate));65 //执行绘画
66 CGContextStrokePath(ctx);67
68
69 //画矩形
70 CGContextSetRGBFillColor(ctx, 244/255.0, 244/255.0, 244/255.0, 1.0);71 //填充矩形
72 CGContextFillRect(ctx, CGRectMake(0, self.height-BOTTOM_VIEW_HEIGHT,Width,5*ScreenHeightRate));73 //执行绘画
74 CGContextStrokePath(ctx);75 }