| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- //
- // InventoryAnalysisViewChartViewController.m
- // IBOSS
- //
- // Created by ssl on 2018/1/4.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "InventoryAnalysisViewChartViewController.h"
- #import "SalesPaymentRankModel.h"
- #import "SalesPaymentRankFrame.h"
- #import "NSString+Tools.h"
- #define kTextFont [UIFont systemFontOfSize:LabelAndTextFontOfSize]
- @interface InventoryAnalysisViewChartViewController (){
-
- /**
- scrollview
- */
- UIScrollView * _scroll;
- /**
- 标题
- */
- UILabel *_lblTitle;
- }
- @end
- @implementation InventoryAnalysisViewChartViewController
- #pragma mark - 公共函数
- /**
- 视图加载完成函数
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initUI];
-
- }
- #pragma mark - 私有函数
- /**
- 初始化UI
- */
- - (void)initUI{
- UIView *separatorView = [UIView new];
- separatorView.tag = 11;
- separatorView.frame = CGRectMake(0, 0, Screen_Width, 10);
- separatorView.backgroundColor = LineBackgroundColor;
- [self.view addSubview:separatorView];
- //柱状图左间距
- _scroll = [UIScrollView new];
- _scroll.frame = CGRectMake(0, CGRectGetMaxY(separatorView.frame), SCREENWIDTH, self.view.frame.size.height-CGRectGetMaxY(separatorView.frame));
- [self.view addSubview:_scroll];
- _lblTitle = [[UILabel alloc]init];
- _lblTitle.text = @"库存按种类进行统计分析的条形图";
- _lblTitle.textAlignment = NSTextAlignmentCenter;
- [_lblTitle sizeToFit];
- _lblTitle.center = CGPointMake(SCREENWIDTH/2,CGRectGetMaxY(separatorView.frame)+5);
- _lblTitle.tag = 10;
- _lblTitle.textColor = LabelGrayTextColor;
- _lblTitle.font = [UIFont systemFontOfSize:14];
- [_scroll addSubview:_lblTitle];
- _bottomSeparatorView = [UIView new];
- _bottomSeparatorView.tag = 10;
- _bottomSeparatorView.hidden = YES;
- _bottomSeparatorView.frame = CGRectMake(0,CGRectGetMaxY(_lblTitle.frame)+5, Screen_Width,2);
- _bottomSeparatorView.backgroundColor=LineBackgroundColor;
- [_scroll addSubview:_bottomSeparatorView];
- self.view.backgroundColor = [UIColor whiteColor];
- }
- /**
- 刷新数据
- */
- - (void)refreshData:(NSString *) str{
- _lblTitle.text = [NSString stringWithFormat:@"库存按%@进行统计分析的条形图",str];
- NSRange range=NSMakeRange(0, 10);
- if(_rankList.count > 10){
- NSRange range = NSMakeRange(0, 10);
- _rankList = [_rankList subarrayWithRange:range];
- }
- Boolean flag = [self isHaveNegativeValue];
- if(flag){
- [self loadNegativeHistogram];
- }
- else{
- [self loadPositiveHistogram];
- }
- }
- /**
- 判断是否有负数
- @return <#return value description#>
- */
- - (Boolean) isHaveNegativeValue{
- Boolean flag = NO;
- for(int i = 0;i < _rankList.count;i++){
- SalesPaymentRankFrame *frame = [_rankList objectAtIndex:i];
- double backAmount = [frame.paymentRankModel.inventoryQuantity doubleValue];
- if(backAmount < 0){
- flag = true;
- break;
- }
- }
- return flag;
- }
- /**
- 绘制向右的柱状图
- @param subview
- @param frame
- */
- - (void)layerToRight:(UIView *) subview withFrame:(CGRect) frame withColor:(UIColor *) color
- {
- CGFloat x = frame.origin.x;
- CGFloat y = frame.origin.y;
- CGFloat height = frame.size.height;
- CGFloat width = frame.size.width;
- CAGradientLayer *itemLayer = [CAGradientLayer layer];
- itemLayer.frame = frame;
- itemLayer.colors = [self getColorArr];
- itemLayer.locations = @[@0,@0.5];
- itemLayer.startPoint = CGPointMake(0, 0);
- itemLayer.endPoint = CGPointMake(0, 1.0);
- [subview.layer addSublayer:itemLayer];
- CABasicAnimation *aniBounds = [CABasicAnimation animationWithKeyPath:@"bounds"];
- aniBounds.fromValue = [NSValue valueWithCGRect:CGRectMake(x, y, 0, height)];
- aniBounds.toValue = [NSValue valueWithCGRect:CGRectMake(x, y, CGRectGetWidth(frame), CGRectGetHeight(frame))];
- CABasicAnimation *aniPosition = [CABasicAnimation animationWithKeyPath:@"position"];
- aniPosition.fromValue = [NSValue valueWithCGPoint:CGPointMake(x, frame.size.height/2 + y)];
- aniPosition.toValue = [NSValue valueWithCGPoint:CGPointMake(x + (CGRectGetMaxX(frame)-x)/2,y + (CGRectGetMaxY(frame)-y)/2)];
- CAAnimationGroup *anis = [CAAnimationGroup animation];
- anis.animations = @[aniBounds,aniPosition];
- anis.duration = 1;
- anis.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
- anis.removedOnCompletion = NO;
- anis.fillMode=kCAFillModeForwards;
- [itemLayer addAnimation:anis forKey:nil];
- }
- /**
- 绘制向左的柱状图
- @param subview
- @param frame
- */
- - (void)layerToLeft:(UIView *) subview withFrame:(CGRect) frame withColor:(UIColor *) color
- {
- CGFloat x = frame.origin.x;
- CGFloat y = frame.origin.y;
- CGFloat height = frame.size.height;
- CGFloat width = frame.size.width;
- CAGradientLayer *itemLayer = [CAGradientLayer layer];
- itemLayer.frame = frame;
- itemLayer.colors = [self getColorArr];
- itemLayer.locations = @[@0,@0.5];
- itemLayer.startPoint = CGPointMake(0, 0);
- itemLayer.endPoint = CGPointMake(0, 1.0);
- [subview.layer addSublayer:itemLayer];
- CABasicAnimation *aniBounds = [CABasicAnimation animationWithKeyPath:@"bounds"];
- aniBounds.fromValue = [NSValue valueWithCGRect:CGRectMake(x, y, 0, height)];
- aniBounds.toValue = [NSValue valueWithCGRect:CGRectMake(x, y, CGRectGetWidth(frame), CGRectGetHeight(frame))];
- CABasicAnimation *aniPosition = [CABasicAnimation animationWithKeyPath:@"position"];
- aniPosition.toValue = [NSValue valueWithCGPoint:CGPointMake(x+ (CGRectGetMaxX(frame)-x)/2, frame.size.height/2 + y)];
- aniPosition.fromValue = [NSValue valueWithCGPoint:CGPointMake(x+width,y + (CGRectGetMaxY(frame)-y)/2)];
- CAAnimationGroup *anis = [CAAnimationGroup animation];
- anis.animations = @[aniBounds,aniPosition];
- anis.duration = 1;
- anis.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
- anis.removedOnCompletion = NO;
- anis.fillMode=kCAFillModeForwards;
- [itemLayer addAnimation:anis forKey:nil];
- }
- /**
- 刷新正向柱状图
- */
- - (void) loadPositiveHistogram{
- for (UIView *subview in _scroll.subviews) {
- if(subview.tag != 10) {
- [subview removeFromSuperview];
- }
- }
- self.view.backgroundColor = [UIColor whiteColor];
-
- CGFloat xSpacing =30;
- //柱状图高度
- CGFloat height = 40;
- //第一个柱状图上间距
- CGFloat fySpacing = 15;
- //柱状图间距
- CGFloat ySpacing = 10;
- //柱状图内文字左间距
- CGFloat xTextSpacing = 5;
- //柱状图最大长度
- CGFloat maxWidth = SCREENWIDTH - xSpacing - 10;
- _histogramView = [[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(_bottomSeparatorView.frame),Screen_Width,[self getHistogramHeight:_rankList])];
- [_scroll addSubview:_histogramView];
- _histogramView.backgroundColor = [UIColor whiteColor];
- SalesPaymentRankFrame *maxBackFrame= [_rankList objectAtIndex:0];
- double maxBackAmount=[maxBackFrame.paymentRankModel.inventoryQuantity doubleValue] ;
- if(_rankList.count >=3){
- [self createAxis:maxWidth maxAmount:maxBackAmount];
- }
- //画水平柱状图
- for(int i=0;i<_rankList.count;i++){
- SalesPaymentRankFrame *frame= [_rankList objectAtIndex:i];
- double backAmount= [frame.paymentRankModel.inventoryQuantity doubleValue];
- NSString *objectName= frame.paymentRankModel.objectName;
- CGFloat width;
- //计算长度
- if(backAmount<maxBackAmount){
- width=maxWidth*(fabs(backAmount)/maxBackAmount);
- if(width<1){
- width=1;
- }
- }
- else{
- width=maxWidth;
- }
-
- [self layerToRight:_histogramView withFrame:CGRectMake(xSpacing, fySpacing*(i+1)+height*i,width, height)withColor:[UIColor colorWithRed:96.0/255.0 green:159.0/255.0 blue:233.0/255.0 alpha:1]];
- [self.view addSubview:_histogramView];
- UILabel *lblOrderSort = [[UILabel alloc] init];
- NSString *orderSortStr =[NSString stringWithFormat:@"%ld", (long)frame.paymentRankModel.orderSort];
- orderSortStr = [NSString stringWithFormat:@"%d",i+1];
- CGRect orderSortFrame = [orderSortStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:@{NSFontAttributeName:kTextFont}];
-
- orderSortFrame.origin.x=10;
- orderSortFrame.origin.y=(height - orderSortFrame.size.height)/2 + fySpacing*(i+1)+height*i;
- lblOrderSort.frame=orderSortFrame;
- lblOrderSort.font = kTextFont;
- lblOrderSort.text = orderSortStr;
- [_histogramView addSubview:lblOrderSort];
- UILabel *lblDepartmentName = [[UILabel alloc] init];
- NSString *departmentNameStr = [NSString stringWithFormat:@"%@ 占比:%@%@",frame.paymentRankModel.objectName,frame.paymentRankModel.backPercent,@"%"];
- CGRect departmentNameFrame = [departmentNameStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:@{NSFontAttributeName:kTextFont}];
- departmentNameFrame.origin.x = xTextSpacing + xSpacing;
- departmentNameFrame.origin.y = 5+ fySpacing*(i+1)+height*i;
- lblDepartmentName.textAlignment = NSTextAlignmentRight;
- lblDepartmentName.frame=departmentNameFrame;
- lblDepartmentName.font = kTextFont;
- lblDepartmentName.text = departmentNameStr;
- [_histogramView addSubview:lblDepartmentName];
- UILabel *lblBackAmount = [[UILabel alloc] init];
- NSString *backAmountStr = [NSString stringWithFormat:@"结存量:%.2f 可售量:%.2f", [frame.paymentRankModel.inventoryQuantity doubleValue],[frame.paymentRankModel.canSaleQuantity doubleValue]];
- CGRect backAmountFrame = [backAmountStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:@{NSFontAttributeName:kTextFont}];
- backAmountFrame.origin.x = xTextSpacing + xSpacing;
- backAmountFrame.origin.y = CGRectGetMaxY(lblDepartmentName.frame);
- lblBackAmount.textAlignment = NSTextAlignmentRight;
- lblBackAmount.frame=backAmountFrame;
- lblBackAmount.font = kTextFont;
- lblBackAmount.text = backAmountStr;
- [_histogramView addSubview:lblBackAmount];
- }
-
- _scroll.contentSize = CGSizeMake(self.view.frame.size.width, CGRectGetMaxY(_histogramView.frame)+10+rectStatusHeight+rectNavHeight + 150);
- [_scroll addSubview:_histogramView];
-
- }
- /**
- 刷新反向柱状图
- */
- - (void) loadNegativeHistogram{
- for (UIView *subview in _scroll.subviews) {
- if(subview.tag != 10) {
- [subview removeFromSuperview];
- }
- }
- //柱状图左间距
- CGFloat xSpacing = 15;
- //柱状图高度
- CGFloat height = 40;
- //第一个柱状图上间距
- CGFloat fySpacing =15;
- //柱状图间距
- CGFloat ySpacing = 10;
- //柱状图内文字左间距
- CGFloat xTextSpacing = 5;
- //柱状图最大长度
- CGFloat maxWidth = SCREENWIDTH/2 - xSpacing - 10;
- _histogramView = [[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(_bottomSeparatorView.frame),Screen_Width,[self getHistogramHeight:_rankList])];
- [_scroll addSubview:_histogramView];
- _histogramView.backgroundColor = [UIColor whiteColor];
- SalesPaymentRankFrame *maxBackFrame = [_rankList objectAtIndex:0];
- SalesPaymentRankFrame *minBackFrame = [_rankList objectAtIndex:_rankList.count - 1];
- //获得最大值绝对值
- double maxBackAmount;
- double firstAmount = [maxBackFrame.paymentRankModel.inventoryQuantity doubleValue];
- double lastAmount = [minBackFrame.paymentRankModel.inventoryQuantity doubleValue];
- if(fabs(firstAmount)>fabs(lastAmount)){
- maxBackAmount = firstAmount;
- }else{
- maxBackAmount = fabs(lastAmount);
- }
- [self createNegativeAxis:maxWidth maxAmount:maxBackAmount];
- //画柱状图
- for(int i=0;i<_rankList.count;i++){
- SalesPaymentRankFrame *frame = [_rankList objectAtIndex:i];
- double backAmount = [frame.paymentRankModel.inventoryQuantity doubleValue];
- NSString *objectName = frame.paymentRankModel.objectName;
- CGFloat width;
- //计算长度
- if(backAmount<maxBackAmount){
- width = maxWidth*(fabs(backAmount)/maxBackAmount);
- if(width < 1){
- width = 1;
- }
- }
- else{
- width=maxWidth;
- }
- //文字
- UILabel *lblBackAmount = [[UILabel alloc] init];
- NSString *backAmountStr = [NSString stringWithFormat:@"¥%.2f",[frame.paymentRankModel.inventoryQuantity doubleValue]];
- CGRect backAmountFrame = [backAmountStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:@{NSFontAttributeName:kTextFont}];
-
- UILabel *lblOrderSort = [[UILabel alloc] init];
- NSString *orderSortStr = [NSString stringWithFormat:@"%ld",(long)frame.paymentRankModel.orderSort];
- CGRect orderSortFrame = [orderSortStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:@{NSFontAttributeName:kTextFont}];
- UILabel *lblDepartmentName = [[UILabel alloc] init];
- NSString *objectNameStr =[frame.paymentRankModel objectName];
- CGRect objectNameFrame = [objectNameStr textRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) attributes:@{NSFontAttributeName:kTextFont}];
- if(backAmount>=0){
- [self layerToRight:_histogramView withFrame:CGRectMake(Screen_Width/2, fySpacing*(i+1)+height*i,width, height)withColor:[UIColor colorWithRed:96.0/255.0 green:159.0/255.0 blue:233.0/255.0 alpha:1]];
- objectNameFrame.origin.x = xTextSpacing+Screen_Width/2;
- objectNameFrame.origin.y = 5 + fySpacing*(i+1)+height*i;
- backAmountFrame.origin.x = xTextSpacing+Screen_Width/2;
- backAmountFrame.origin.y = CGRectGetMaxY(objectNameFrame);
- orderSortFrame.origin.x = Screen_Width/2-xSpacing;
- orderSortFrame.origin.y = (height - orderSortFrame.size.height)/2 + fySpacing*(i+1)+height*i;
- }
- //负值
- else if(backAmount < 0){
- [self layerToLeft:_histogramView withFrame:CGRectMake(Screen_Width/2-width, fySpacing*(i+1)+height*i,width, height)withColor:[UIColor colorWithRed:96.0/255.0 green:159.0/255.0 blue:233.0/255.0 alpha:1]];
- objectNameFrame.origin.x = Screen_Width/2-xTextSpacing-CGRectGetWidth(objectNameFrame);
- objectNameFrame.origin.y = 5 + fySpacing*(i+1)+height*i;
- backAmountFrame.origin.x = Screen_Width/2-xTextSpacing-CGRectGetWidth(backAmountFrame);
- backAmountFrame.origin.y = CGRectGetMaxY(objectNameFrame);
- orderSortFrame.origin.x =Screen_Width/2+xTextSpacing;
- orderSortFrame.origin.y = (height - orderSortFrame.size.height)/2 + fySpacing*(i+1)+height*i;
-
- }
- [self.view addSubview:_histogramView];
- UIView *yAxis=[[UIView alloc]init];
- yAxis.frame=CGRectMake(Screen_Width/2, 0, 2.5, [self getHistogramHeight:_rankList]);
- yAxis.backgroundColor=LineBackgroundColor;
- [_histogramView addSubview:yAxis];
- lblDepartmentName.frame = objectNameFrame;
- lblDepartmentName.font = kTextFont;
- lblDepartmentName.text = objectNameStr;
- [_histogramView addSubview:lblDepartmentName];
- lblOrderSort.frame = orderSortFrame;
- lblOrderSort.font = kTextFont;
- lblOrderSort.text = orderSortStr;
- [_histogramView addSubview:lblOrderSort];
-
- lblBackAmount.textAlignment = NSTextAlignmentRight;
- lblBackAmount.frame = backAmountFrame;
- lblBackAmount.font = kTextFont;
- lblBackAmount.text = backAmountStr;
- [_histogramView addSubview:lblBackAmount];
- }
-
- _scroll.contentSize = CGSizeMake(self.view.frame.size.width, CGRectGetMaxY(_histogramView.frame)+10+rectStatusHeight+rectNavHeight + 150);
- [_scroll addSubview:_histogramView];
-
- }
- /**
- 计算柱状图的高度
- @param dataList <#dataList description#>
- @return <#return value description#>
- */
- -(CGFloat)getHistogramHeight:(NSArray*)dataList{
- // 上下间隔已经在frame上做了
- NSInteger row = dataList.count;
- return (row * 40 + (row * 15));
- }
- /**
- 创建负数的轴线
-
- @param width 最大长度
- @param maxAmount 最大金额
- */
- - (void) createNegativeAxis:(CGFloat) width maxAmount:(CGFloat)maxAmount{
- // 线的路径
- UIBezierPath *leveLinePath = [UIBezierPath bezierPath];
- // 起点
- [leveLinePath moveToPoint:CGPointMake((_histogramView.frame.size.width - (2 * width))/2, 0)];
- // 其他点
- [leveLinePath addLineToPoint:CGPointMake(2 * width + 10, 0)];
- CAShapeLayer *leveLineLayer = [CAShapeLayer layer];
- leveLineLayer.lineWidth = 1;
- leveLineLayer.strokeColor = LineBackgroundColor.CGColor;
- leveLineLayer.path = leveLinePath.CGPath;
- leveLineLayer.fillColor = nil; // 默认为blackColor
- [_histogramView.layer addSublayer:leveLineLayer];
-
- NSString *str = [NSString stringWithFormat:@"%d",(int)maxAmount];
- int m = ceil([str integerValue]/pow(10, str.length-1));
- m = m * pow(10, str.length-1);
- m = 5000100.00;
- //右侧垂直等份轴线
- for (int i = 0; i <= 3; i++) {
- if(i != 0){
- CGFloat c = (width/3)*i+width+10;
- // if(i != 0){
- // UILabel *lb = [[UILabel alloc] initWithFrame:CGRectMake(c-20, _histogramView.frame.origin.y-17, 200, 17)];
- // lb.textAlignment = NSTextAlignmentCenter;
- // lb.center = CGPointMake(c-10, _histogramView.frame.origin.y-10);
- // lb.text = [NSString stringWithFormat:@"%d",(m/5)*i];
- // lb.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1];
- // lb.font = [UIFont systemFontOfSize:9];
- // [_scroll addSubview:lb];
- // }
- UIBezierPath *linePath = [UIBezierPath bezierPath];
- [linePath moveToPoint:CGPointMake(c, 0)];
- [linePath addLineToPoint:CGPointMake(c, _histogramView.frame.size.height)];
- CAShapeLayer *lineLayer = [CAShapeLayer layer];
-
- lineLayer.lineWidth = 1;
- lineLayer.strokeColor = LineBackgroundColor.CGColor;
- lineLayer.path = linePath.CGPath;
- lineLayer.fillColor = nil; // 默认为blackColor
- [_histogramView.layer addSublayer:lineLayer];
- }
- }
- //左侧垂直等份轴线
- for (int i = 0; i <= 3; i++) {
- //计算等分间距
- CGFloat c = width + 10 -(width/3)*i;
- if(i != 0){
- UIBezierPath *linePath = [UIBezierPath bezierPath];
- [linePath moveToPoint:CGPointMake(c, 0)];
- [linePath addLineToPoint:CGPointMake(c, _histogramView.frame.size.height)];
- CAShapeLayer *lineLayer = [CAShapeLayer layer];
-
- lineLayer.lineWidth = 1;
- lineLayer.strokeColor = LineBackgroundColor.CGColor;
- lineLayer.path = linePath.CGPath;
- lineLayer.fillColor = nil; // 默认为blackColor
- [_histogramView.layer addSublayer:lineLayer];
- }
- }
- }
- /**
- 创建正数的轴线
-
- @param width <#width description#>
- @param maxAmount <#maxAmount description#>
- */
- - (void) createAxis:(CGFloat) width maxAmount:(CGFloat)maxAmount{
- // 线的路径
- UIBezierPath *linePath = [UIBezierPath bezierPath];
- // 起点
- [linePath moveToPoint:CGPointMake(width+30, 0)];
- // 其他点
- [linePath addLineToPoint:CGPointMake(30, 0)];
- [linePath addLineToPoint:CGPointMake(30,_histogramView.frame.size.height)];
-
- CAShapeLayer *lineLayer = [CAShapeLayer layer];
-
- lineLayer.lineWidth = 1;
- lineLayer.strokeColor = LineBackgroundColor.CGColor;
- lineLayer.path = linePath.CGPath;
- lineLayer.fillColor = nil; // 默认为blackColor
- [_histogramView.layer addSublayer:lineLayer];
- NSString *str = [NSString stringWithFormat:@"%d",(int)maxAmount];
- int m = ceil([str integerValue]/pow(10, str.length-1));
- m = m * pow(10, str.length-1);
- //垂直五条轴线
- for (int i = 0; i <= 5; i++) {
- CGFloat c = (width/5)*i+30;
- // if(i != 0){
- // UILabel *lb = [[UILabel alloc] initWithFrame:CGRectMake(c-20, _histogramView.frame.origin.y-17, 200, 17)];
- // lb.textAlignment = NSTextAlignmentCenter;
- // lb.center = CGPointMake(c-10, _histogramView.frame.origin.y-10);
- // lb.text = [NSString stringWithFormat:@"%d",(m/5)*i];
- // lb.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1];
- // lb.font = [UIFont systemFontOfSize:9];
- // [_scroll addSubview:lb];
- // }
- UIBezierPath *linePath = [UIBezierPath bezierPath];
- [linePath moveToPoint:CGPointMake(c, 0)];
- [linePath addLineToPoint:CGPointMake(c, _histogramView.frame.size.height)];
- CAShapeLayer *lineLayer = [CAShapeLayer layer];
-
- lineLayer.lineWidth = 1;
- lineLayer.strokeColor = LineBackgroundColor.CGColor;
- lineLayer.path = linePath.CGPath;
- lineLayer.fillColor = nil; // 默认为blackColor
- [_histogramView.layer addSublayer:lineLayer];
-
- }
- }
- /**
- 渐变色
-
- @return <#return value description#>
- */
- -(NSMutableArray *) getColorArr{
- NSMutableArray *arr = [NSMutableArray array];
- [arr addObject:(__bridge id)[UIColor colorWithRed:236/255.0 green:134/255.0 blue:40/255.0 alpha:1].CGColor];
- [arr addObject:(__bridge id)[UIColor colorWithRed:236/255.0 green:134/255.0 blue:40/255.0 alpha:0.4].CGColor];
- [arr addObject:(__bridge id)[UIColor colorWithRed:236/255.0 green:134/255.0 blue:40/255.0 alpha:1].CGColor];
- return arr;
- }
- @end
|