From 3e8437ae559487362fae3525beb79c534c213a51 Mon Sep 17 00:00:00 2001 From: 单军华 Date: Thu, 12 Jul 2018 13:44:34 +0800 Subject: [PATCH] bug修复和功能优化 --- screendisplay/screendisplay/Classes/ThirdClass/JHChart/JHChart.m | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 159 insertions(+), 0 deletions(-) diff --git a/screendisplay/screendisplay/Classes/ThirdClass/JHChart/JHChart.m b/screendisplay/screendisplay/Classes/ThirdClass/JHChart/JHChart.m new file mode 100755 index 0000000..db3c549 --- /dev/null +++ b/screendisplay/screendisplay/Classes/ThirdClass/JHChart/JHChart.m @@ -0,0 +1,159 @@ +// +// JHChart.m +// JHChartDemo +// +// Created by cjatech-������ on 16/4/10. +// Copyright �� 2016��� JH. All rights reserved. +// + +#import "JHChart.h" +@interface JHChart() + + + +@end +@implementation JHChart + +/* +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect { + // Drawing code +} +*/ + +-(void)showAnimation{ + +} + + +-(void)clear{ + +} + + +/** + * ������������ + * + * @param context ��������������������� + * @param start ������ + * @param end ������ + * @param isDotted ��������������� + * @param color ������������ + */ +- (void)drawLineWithContext:(CGContextRef )context andStarPoint:(CGPoint )start andEndPoint:(CGPoint)end andIsDottedLine:(BOOL)isDotted andColor:(UIColor *)color{ + + + // ������������ + CGContextMoveToPoint(context, start.x, start.y); + // ��������� + CGContextAddLineToPoint(context, end.x, end.y); + + + CGContextSetLineWidth(context, 0.5); + + + [color setStroke]; + + if (isDotted) { + CGFloat ss[] = {0.5,2}; + + CGContextSetLineDash(context, 0, ss, 2); + } + CGContextMoveToPoint(context, end.x, end.y); + + CGContextDrawPath(context, kCGPathFillStroke); +} + + +/** + * ������������ + * + * @param text ������������ + * @param context ��������������������� + * @param rect ��������� + * @param color ������������ + */ +- (void)drawText:(NSString *)text andContext:(CGContextRef )context atPoint:(CGPoint )rect WithColor:(UIColor *)color andFontSize:(CGFloat)fontSize{ + + + [[NSString stringWithFormat:@"%@",text] drawAtPoint:rect withAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize],NSForegroundColorAttributeName:color}]; + + [color setFill]; + + CGContextDrawPath(context, kCGPathFill); + +} + + +- (void)drawText:(NSString *)text context:(CGContextRef )context atPoint:(CGRect )rect WithColor:(UIColor *)color font:(UIFont*)font{ + + +// [[NSString stringWithFormat:@"%@",text] drawAtPoint:rect withAttributes:@{NSFontAttributeName:font,NSForegroundColorAttributeName:color}]; + + [[NSString stringWithFormat:@"%@",text] drawInRect:rect withAttributes:@{NSFontAttributeName:font,NSForegroundColorAttributeName:color}]; + + [color setFill]; + + + CGContextDrawPath(context, kCGPathFill); + +} +/** + * ������������������ + * + * @param text ������������ + * + * @return ������������ + */ +- (CGFloat)getTextWithWhenDrawWithText:(NSString *)text{ + + CGSize size = [[NSString stringWithFormat:@"%@",text] boundingRectWithSize:CGSizeMake(100, 15) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:7]} context:nil].size; + + return size.width; +} + + +/** + * ��������������� + * + * @param color ������������ + * @param p ��������� + * @param contex ��������������� + */ +- (void)drawQuartWithColor:(UIColor *)color andBeginPoint:(CGPoint)p andContext:(CGContextRef)contex{ + + CGContextAddRect(contex, CGRectMake(p.x, p.y, 10, 10)); + [color setFill]; + [color setStroke]; + CGContextDrawPath(contex, kCGPathFillStroke); + + +} + + +- (void)drawPointWithRedius:(CGFloat)redius andColor:(UIColor *)color andPoint:(CGPoint)p andContext:(CGContextRef)contex{ + + CGContextAddArc(contex, p.x, p.y, redius, 0, M_PI * 2, YES); + [color setFill]; + CGContextDrawPath(contex, kCGPathFill); + +} + +/** + * ������������������������������ + * + * @param maxSize ������������ + * @param fontSize ������������ + * @param aimString ��������������� + * + * @return ������������ + */ +- (CGSize)sizeOfStringWithMaxSize:(CGSize)maxSize textFont:(CGFloat)fontSize aimString:(NSString *)aimString{ + + + return [aimString boundingRectWithSize:maxSize options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]} context:nil].size; + +} + +@end -- Gitblit v1.8.0