IOS 股票K线图的实现

 2015-09-04 by 木易哥哥 

智者精选,每天获取励志认知能量 www.5izhjx.com


写了lines、RKLineView、getData三个对象完成实现。

首先开始调用

rkLine = [[RKLineViewalloc]init];

        CGRect frame =riKView.frame;

         frame.origin =CGPointMake(0,5);

         frame.size =CGSizeMake(315,219);

        rkLine.frame = frame;

        rkLine.xWidth =315;

        rkLine.yHeight =219;

         rkLine.kLineWidth =4;

         rkLine.kLinePadding =1.25;

        rkLine.riKArry = [dicobjectForKey:@"rows"];


         [riKViewaddSubview:rkLine];

         [rkLinestart];// 线图运行



其它3个对象部分代码如下

#import <UIKit/UIKit.h>


@interface lines : UIView

@property (nonatomic,assign)CGPoint startPoint;//线条起点

@property (nonatomic,assign)CGPoint endPoint;//线条终点

@property (nonatomic,retain)NSArray *points;//多点连线数组

@property (nonatomic,retain)NSString *color;//线条颜色

@property (nonatomic,assign)CGFloat lineWidth;//线条宽度

@property (nonatomic,assign)BOOL isK;//是否是实体K线默认是连接线

@property (nonatomic,assign)BOOL isVol;//是否是画成交量的实体

@end



#import "lines.h"

#import "colorModel.h"

#import "UIColor+helper.h"


@interface lines(){


}

@end


@implementation lines


- (id)initWithFrame:(CGRect)frame

{

   self = [superinitWithFrame:frame];

   if (self) {

        // Initialization code

        [selfinitSet];

    }

    return self;

}


#pragma mark 初始化参数

-(void)initSet{

    self.backgroundColor = [UIColorclearColor];

   self.startPoint =self.frame.origin;

   self.endPoint =self.frame.origin;

    self.color =@"#000000";

   self.lineWidth =1.0f;

   self.isK =NO;

   self.isVol =NO;

}



-(void)drawRect:(CGRect)rect

{

    CGContextRef context =UIGraphicsGetCurrentContext();//获取绘图上下文

   if (self.isK) {

       //k线

       for (NSArray *iteminself.points) {

           //转换坐标

           CGPoint heightPoint,lowPoint,openPoint,closePoint;

            heightPoint =CGPointFromString([itemobjectAtIndex:0]);

            lowPoint =CGPointFromString([itemobjectAtIndex:1]);

            openPoint =CGPointFromString([itemobjectAtIndex:2]);

            closePoint =CGPointFromString([itemobjectAtIndex:3]);

            [selfdrawKWithContext:contextheight:heightPoint Low:lowPoint open:openPoint close:closePoint width:self.lineWidth];

        }

        

    }else{

       //画连接线

        [selfdrawLineWithContext:context];

    }

}

#pragma mark 画连接线

-(void)drawLineWithContext:(CGContextRef)context{

    CGContextSetLineWidth(context,self.lineWidth);

    //NSLog(@"self.lineWidth:%f",self.lineWidth);

    CGContextSetShouldAntialias(context,YES);

   colorModel *colormodel = [UIColorRGBWithHexString:self.colorwithAlpha:self.alpha];//设置颜色

   CGContextSetRGBStrokeColor(context, (CGFloat)colormodel.R/255.0f, (CGFloat)colormodel.G/255.0f, (CGFloat)colormodel.B/255.0f,self.alpha);

    if (self.startPoint.x==self.endPoint.x && self.endPoint.y==self.startPoint.y) {

        // 定义多个个点 画多点连线

       for (id iteminself.points) {

           CGPoint currentPoint =CGPointFromString(item);

           if ((int)currentPoint.y<(int)self.frame.size.height && currentPoint.y>0) {

               if ([self.pointsindexOfObject:item]==0) {

                   CGContextMoveToPoint(context, currentPoint.x, currentPoint.y);

                   continue;

                }

               CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y);

               CGContextStrokePath(context);//开始画线

               if ([self.pointsindexOfObject:item]<self.points.count) {

                   CGContextMoveToPoint(context, currentPoint.x, currentPoint.y);

                }

                

            }

        }

    }else{

        // 定义两个点 画两点连线

       constCGPoint points[] = {self.startPoint,self.endPoint};

       CGContextStrokeLineSegments(context, points,2);  // 绘制线段(默认不绘制端点)

    }

}


#pragma mark 画一根K线

-(void)drawKWithContext:(CGContextRef)context height:(CGPoint)heightPoint Low:(CGPoint)lowPoint open:(CGPoint)openPoint close:(CGPoint)closePoint width:(CGFloat)width{

    CGContextSetShouldAntialias(context,NO);

    //首先判断是绿的还是红的,根据开盘价和收盘价的坐标来计算

   BOOL isKong =NO;

   colorModel *colormodel = [UIColorRGBWithHexString:@"#FF0000"withAlpha:self.alpha];//设置默认红色

    //如果开盘价坐标在收盘价坐标上方则为绿色即空

   if (openPoint.y<closePoint.y) {

        isKong =YES;

        colormodel = [UIColorRGBWithHexString:@"#00a900"withAlpha:self.alpha];//设置为绿色

    }

    // 设置颜色

   CGContextSetRGBStrokeColor(context, (CGFloat)colormodel.R/255.0f, (CGFloat)colormodel.G/255.0f, (CGFloat)colormodel.B/255.0f,self.alpha);

    //首先画一个垂直的线包含上影线和下影线

    //定义两个点画两点连线

   if (!self.isVol) {

       CGContextSetLineWidth(context,1); // 上下阴影线的宽度

       if (self.lineWidth<=2) {

           CGContextSetLineWidth(context,0.5); // 上下阴影线的宽度

        }

       constCGPoint points[] = {heightPoint,lowPoint};

       CGContextStrokeLineSegments(context, points,2);  // 绘制线段(默认不绘制端点)

    }

    // 再画中间的实体

   CGContextSetLineWidth(context, width);// 改变线的宽度

   CGFloat halfWidth =0;//width/2;

    //纠正实体的中心点为当前坐标

    openPoint =CGPointMake(openPoint.x-halfWidth, openPoint.y);

    closePoint =CGPointMake(closePoint.x-halfWidth, closePoint.y);

   if (self.isVol) {

        openPoint =CGPointMake(heightPoint.x-halfWidth, heightPoint.y);

        closePoint =CGPointMake(lowPoint.x-halfWidth, lowPoint.y);

    }

    // 开始画实体

   constCGPoint point[] = {openPoint,closePoint};

    CGContextStrokeLineSegments(context, point,2); // 绘制线段(默认不绘制端点)

}



@end


#import <UIKit/UIKit.h>


typedefvoid(^updateBlock)(id);


@interface RKLineView :UIView


@property (nonatomic,copy)updateBlock finishUpdateBlock; // 定义一个block回调更新界面


@property (nonatomic,assign)CGFloat xWidth;// x轴宽度

@property (nonatomic,assign)CGFloat yHeight;// y轴高度

@property (nonatomic,assign)CGFloat bottomBoxHeight;// y轴高度

@property (nonatomic,assign)CGFloat kLineWidth;// k线的宽度 用来计算可存放K线实体的个数,也可以由此计算出起始日期和结束日期的时间段

@property (nonatomic,assign)CGFloat kLinePadding;

@property (nonatomic,assign)int kCount;// k线中实体的总数 通过 xWidth / kLineWidth 计算而来

@property (nonatomic,retain)UIFont *font;


@property (nonatomic,retain)NSMutableArray *data;

@property (nonatomic,retain)NSDate *startDate;

@property (nonatomic,retain)NSDate *endDate;


@property (nonatomic,retain)NSMutableArray *riKArry;//分时数据数组

@property (nonatomic,retain)NSString *jrkp;//今日开盘

@property (nonatomic,retain)NSString *zrsp;//昨日收盘


-(void)start;

-(void)update;

@end


#import "RKLineView.h"

#import "lines.h"

#import "UIColor+helper.h"

#import "getData.h"

#import "commond.h"


@interface RKLineView()

{

   NSThread *thread;

   UIView *mainboxView;// k线图控件

   UIView *bottomBoxView;// 成交量

   getData *getdata;

    

   UIView *movelineone;// 手指按下后显示的两根白色十字线

   UIView *movelinetwo;

    

   UIView *xxView;//展现信息

   UILabel *riqLable;//日期

   UILabel *kpLable;//开盘

   UILabel *zgLable;//最高

   UILabel *zdLable;//最低

   UILabel *spLable;//收盘

   UILabel *cjlLable;//成交量

   UILabel *cjeLable;//成交额

   UILabel *zflLable;//涨幅

    

   UILabel *movelinetwoLable;

    

   NSMutableArray *pointArray;// k线所有坐标数组

    

   UILabel *startDateLab;

   UILabel *endDateLab;

    

   UILabel *volMaxValueLab;// 显示成交量最大值

    

   BOOL isUpdate;

   BOOL isUpdateFinish;

    

   NSMutableArray *lineArray ;// k线数组

   NSMutableArray *lineOldArray ;// k线数组

    UIPinchGestureRecognizer *pinchGesture;

   CGPoint touchViewPoint;

   BOOL isPinch;

    

   UILabel *MA5;// 5均线显示

   UILabel *MA10;// 10均线

   UILabel *MA20;// 20均线

    

   UILabel *jg1;//价格1

   UILabel *jg2;//价格2

   UILabel *jg3;//价格3

   UILabel *jg4;//价格4

   UILabel *jg5;//价格5

    

   UILabel *zfl1;//涨幅率1

   UILabel *zfl2;//涨幅率2

   UILabel *zfl3;//涨幅率3

   UILabel *zfl4;//涨幅率4

   UILabel *zfl5;//涨幅率5

    

   UILabel *shou1;//1

   UILabel *shou2;//2

   UILabel *shou3;//3

}

@end


@implementation RKLineView


-(id)init{

   self = [superinit];

    [selfinitSet];

    return self;

}


-(void)initSet

{

    

    self.font = [UIFontsystemFontOfSize:8];

   isUpdate =NO;

    isUpdateFinish =YES;

   isPinch =NO;

    

   lineArray = [[NSMutableArrayalloc]init];

   lineOldArray = [[NSMutableArrayalloc]init];

    

    self.finishUpdateBlock = ^(idself){

        [selfupdateNib];//十字线显示的view

    };

}


#pragma mark 更新界面等信息

-(void)updateNib{

    //NSLog(@"block");

   if (movelineone==Nil) {

        movelineone = [[UIViewalloc]initWithFrame:CGRectMake(0,0,0.5,

                                                              bottomBoxView.frame.size.height+bottomBoxView.frame.origin.y)];

        movelineone.backgroundColor = [UIColorcolorWithHexString:@"#333333"withAlpha:0.5];

        [mainboxViewaddSubview:movelineone];

       movelineone.hidden =YES;

    }

   if (movelinetwo==Nil) {

       movelinetwo = [[UIViewalloc]initWithFrame:CGRectMake(0,0,mainboxView.frame.size.width,1)];

        movelinetwo.backgroundColor = [UIColorcolorWithHexString:@"#333333"withAlpha:0.5];

       movelinetwo.hidden =YES;

        [mainboxViewaddSubview:movelinetwo];

    }

   if (xxView==Nil) {

       CGRect oneFrame =movelineone.frame;

        oneFrame.size =CGSizeMake(60,73);

       xxView = [[UIViewalloc]initWithFrame:oneFrame];

        xxView.backgroundColor = [UIColorcolorWithHexString:@"#333333"withAlpha:1];

       xxView.hidden =YES;

        

        riqLable = [[UILabelalloc]initWithFrame:CGRectMake(2,1,60,8)];

       riqLable.font = [UIFontsystemFontOfSize:8];

       riqLable.textColor = [UIColorwhiteColor];

        

        kpLable = [[UILabelalloc]initWithFrame:CGRectMake(2,10,60,8)];

       kpLable.font = [UIFontsystemFontOfSize:8];

       kpLable.textColor = [UIColorwhiteColor];

        

        zgLable = [[UILabelalloc]initWithFrame:CGRectMake(2,19,60,8)];

       zgLable.font = [UIFontsystemFontOfSize:8];

       zgLable.textColor = [UIColorwhiteColor];

        

        zdLable = [[UILabelalloc]initWithFrame:CGRectMake(2,28,60,8)];

       zdLable.font = [UIFontsystemFontOfSize:8];

       zdLable.textColor = [UIColorwhiteColor];

        

        spLable = [[UILabelalloc]initWithFrame:CGRectMake(2,37,60,8)];

       spLable.font = [UIFontsystemFontOfSize:8];

       spLable.textColor = [UIColorwhiteColor];

        

        cjlLable = [[UILabelalloc]initWithFrame:CGRectMake(2,46,60,8)];

       cjlLable.font = [UIFontsystemFontOfSize:8];

       cjlLable.textColor = [UIColorwhiteColor];

        

        cjeLable = [[UILabelalloc]initWithFrame:CGRectMake(2,55,60,8)];

       cjeLable.font = [UIFontsystemFontOfSize:8];

       cjeLable.textColor = [UIColorwhiteColor];

        

        zflLable = [[UILabelalloc]initWithFrame:CGRectMake(2,64,60,8)];

       zflLable.font = [UIFontsystemFontOfSize:8];

       zflLable.textColor = [UIColorwhiteColor];


        [xxView addSubview:riqLable];

        [xxViewaddSubview:kpLable];

        [xxViewaddSubview:zgLable];

        [xxViewaddSubview:zdLable];

        [xxViewaddSubview:spLable];

        [xxView addSubview:cjlLable];

        [xxView addSubview:cjeLable];

        [xxView addSubview:zflLable];

        [mainboxViewaddSubview:xxView];

    }

    if (movelinetwoLable==Nil) {

       CGRect oneFrame =movelinetwo.frame;

        oneFrame.size =CGSizeMake(36,12);

       movelinetwoLable = [[UILabelalloc]initWithFrame:oneFrame];

        movelinetwoLable.font =self.font;

        movelinetwoLable.layer.cornerRadius =5;

        movelinetwoLable.backgroundColor = [UIColorcolorWithHexString:@"#333333"withAlpha:1];

       movelinetwoLable.textColor = [UIColorwhiteColor];

        movelinetwoLable.textAlignment =UITextAlignmentCenter;

        movelinetwoLable.hidden =YES;

        [mainboxViewaddSubview:movelinetwoLable];

    }

    

    movelineone.frame =CGRectMake(touchViewPoint.x,0,0.5,

                                  bottomBoxView.frame.size.height+bottomBoxView.frame.origin.y);

    movelinetwo.frame =CGRectMake(0,touchViewPoint.y,mainboxView.frame.size.width,0.5);

   CGRect oneFrame =movelineone.frame;

    oneFrame.size =CGSizeMake(60,73);

   xxView.frame = oneFrame;

   CGRect towFrame =movelinetwo.frame;

    towFrame.size =CGSizeMake(36,12);

   movelinetwoLable.frame = towFrame;

    

    movelineone.hidden =NO;

    movelinetwo.hidden =NO;

   xxView.hidden =NO;

    movelinetwoLable.hidden =NO;

    [selfisKPointWithPoint:touchViewPoint];//一点击就显示十字状态

}


-(void)start{

    [selfdrawBox];

    thread = [[NSThreadalloc]initWithTarget:selfselector:@selector(drawLine)object:nil];

    [threadstart];

}


#pragma mark 画框框和平均线

-(void)drawBox{

    // 画个k线图的框框

   if (mainboxView==nil) {

        mainboxView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,315,130)];

        mainboxView.layer.borderColor = [UIColorcolorWithHexString:@"#444444"withAlpha:0.5].CGColor;

        mainboxView.layer.borderWidth =0.5;

        mainboxView.userInteractionEnabled =YES;

        [selfaddSubview:mainboxView];

        //添加手指捏合手势,放大或缩小k线图

       pinchGesture = [[UIPinchGestureRecognizeralloc]initWithTarget:selfaction:@selector(touchBoxAction:)];

        [mainboxViewaddGestureRecognizer:pinchGesture];

        UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizeralloc]init];

        [longPressGestureRecognizeraddTarget:selfaction:@selector(gestureRecognizerHandle:)];

        [longPressGestureRecognizersetMinimumPressDuration:0.3f];

        [longPressGestureRecognizersetAllowableMovement:36.0];

        [selfaddGestureRecognizer:longPressGestureRecognizer];

    }

    

   if (!isUpdate) {

        // k线图分割线

       CGFloat padRealValue =mainboxView.frame.size.height /4;

       for (int i =0; i<4; i++) {

           CGFloat y =mainboxView.frame.size.height-padRealValue * i;

           lines *line = [[linesalloc]initWithFrame:CGRectMake(0,0,mainboxView.frame.size.width,mainboxView.frame.size.height)];

            line.color =@"#999999";

            line.alpha =0.5;

            line.startPoint =CGPointMake(0, y);

            line.endPoint =CGPointMake(mainboxView.frame.size.width, y);

            [mainboxViewaddSubview:line];

        }

    }

    

    //显示开始日期控件

    if (startDateLab==nil) {

        startDateLab = [[UILabelalloc]initWithFrame:CGRectMake(1

                                                                 ,131

                                                                 ,50,8)];

       startDateLab.font = [UIFontsystemFontOfSize:8];

       startDateLab.text =@"--";

       startDateLab.textColor = [UIColorgrayColor];

        startDateLab.backgroundColor = [UIColorclearColor];

        [mainboxViewaddSubview:startDateLab];

    }

    

    //显示结束日期控件

   if (endDateLab==nil) {

        endDateLab = [[UILabelalloc]initWithFrame:CGRectMake(270

                                                               ,131

                                                               ,50,8)];

       endDateLab.font = [UIFontsystemFontOfSize:8];

       endDateLab.text =@"--";

       endDateLab.textColor = [UIColorgrayColor];

        endDateLab.backgroundColor = [UIColorclearColor];

        [mainboxViewaddSubview:endDateLab];

    }

    

    // MA5 均线价格显示控件

   if (MA5==nil) {

       MA5 = [[UILabelalloc]initWithFrame:CGRectMake(100, -8,30,8)];

        MA5.backgroundColor = [UIColorclearColor];

       MA5.font = [UIFontsystemFontOfSize:8];

       MA5.text =@"MA5";

        MA5.textColor = [UIColorcolorWithHexString:@"#d83dd9"withAlpha:1];

        [MA5sizeToFit];

        [selfaddSubview:MA5];

    }

    

    

    // MA10 均线价格显示控件

   if (MA10==nil) {

       MA10 = [[UILabelalloc]initWithFrame:CGRectMake(MA5.frame.origin.x +MA5.frame.size.width +10, -8,30,8)];

        MA10.backgroundColor = [UIColorclearColor];

       MA10.font = [UIFontsystemFontOfSize:8];

       MA10.text =@"MA10";

        MA10.textColor = [UIColorcolorWithHexString:@"#ebac31"withAlpha:1];

        [MA10sizeToFit];

        [selfaddSubview:MA10];

    }

    

    

    // MA20 均线价格显示控件

   if (MA20==nil) {

       MA20 = [[UILabelalloc]initWithFrame:CGRectMake(MA10.frame.origin.x +MA10.frame.size.width +10, -8,30,8)];

        MA20.backgroundColor = [UIColorclearColor];

       MA20.font = [UIFontsystemFontOfSize:8];

       MA20.text =@"MA20";

        MA20.textColor = [UIColorcolorWithHexString:@"#2e87e2"withAlpha:1];

        [MA20sizeToFit];

        [selfaddSubview:MA20];

    }


    //画个成交量的框框

    if (bottomBoxView==nil) {

        bottomBoxView = [[UIViewalloc]initWithFrame:CGRectMake(0,140,315,75)];

        bottomBoxView.layer.borderColor = [UIColorcolorWithHexString:@"#444444"withAlpha:0.5].CGColor;

        bottomBoxView.layer.borderWidth =0.5;

        bottomBoxView.userInteractionEnabled =YES;

        [mainboxViewaddSubview:bottomBoxView];

    }

    

   if (!isUpdate) {

        // 成交量分割线

       CGFloat padRealValue =bottomBoxView.frame.size.height /3;

       for (int i =0; i<3; i++) {

           CGFloat y =bottomBoxView.frame.size.height-padRealValue * i;

           lines *line = [[linesalloc]initWithFrame:CGRectMake(0,0,bottomBoxView.frame.size.width,bottomBoxView.frame.size.height)];

            line.color =@"#999999";

            line.alpha =0.5;

            line.startPoint =CGPointMake(0, y);

            line.endPoint =CGPointMake(bottomBoxView.frame.size.width, y);

            [bottomBoxViewaddSubview:line];

        }

    }

    

   //1

    shou1 = [[UILabelalloc]initWithFrame:CGRectMake(1,141,50,8)];

   shou1.text =@"7.5";

    shou1.font = [UIFontsystemFontOfSize:8];

    [shou1setTextColor:[UIColorgrayColor]];

    [selfaddSubview:shou1];

    

   //2

    shou2 = [[UILabelalloc]initWithFrame:CGRectMake(1,166,50,8)];

   shou2.text =@"5";

    shou2.font = [UIFontsystemFontOfSize:8];

    [shou2setTextColor:[UIColorgrayColor]];

    [selfaddSubview:shou2];

    

   //3

    shou3 = [[UILabelalloc]initWithFrame:CGRectMake(1,191,50,8)];

   shou3.text =@"2.5";

    shou3.font = [UIFontsystemFontOfSize:8];

    [shou3setTextColor:[UIColorgrayColor]];

    [selfaddSubview:shou3];


}


#pragma mark k线

-(void)drawLine{

    self.kCount =self.xWidth / (self.kLineWidth+self.kLinePadding) +1; // K线中实体的总数


   getdata = [[getDataalloc]init];

    getdata.kCount =self.kCount;

    

    [getdata changeRKData:_riKArry];

     self.data =getdata.data;

    

    // 开始画K线图

    [selfdrawBoxWithKline];

    

    //NSLog(@"处理得dddd");

    // 清除旧的k线

    if (lineOldArray.count>0 && isUpdate) {

       for (lines *lineinlineOldArray) {

            [lineremoveFromSuperview];

        }

    }

    lineOldArray =lineArray.copy;

    

    if (_finishUpdateBlock &&isPinch) {

        _finishUpdateBlock(self);

    }

    isUpdateFinish =YES;

    // 结束线程

    [threadcancel];

}



#pragma mark 在框框里画k线

-(void)drawBoxWithKline{

    

    // 平均线

    CGFloat padValue = (getdata.maxValue -getdata.minValue) /4;

   CGFloat padRealValue =mainboxView.frame.size.height /4;

   for (int i =0; i<5; i++) {

       CGFloat y =mainboxView.frame.size.height-padRealValue * i;

       // lable

       UILabel *leftTag = [[UILabelalloc]initWithFrame:CGRectMake(0, y-30/2-3,38,30)];

        leftTag.text = [[NSStringalloc]initWithFormat:@"%.2f",padValue*i+getdata.minValue];

        leftTag.textColor = [UIColorgrayColor];

        leftTag.font =self.font;

        //[leftTag sizeToFit];

        [mainboxViewaddSubview:leftTag];

        [lineArrayaddObject:leftTag];

    }



    

    // 开始画连接均线

    [selfdrawMAWithIndex:7andColor:@"#d83dd9"];//MA5,黄色

    [selfdrawMAWithIndex:8andColor:@"#ebac31"];//MA10,蓝色

    [selfdrawMAWithIndex:9andColor:@"#2e87e2"];//MA20,蓝色


    

    // 开始画连K线

    // x轴从0框框的宽度 mainboxView.frame.size.width变化  y轴为每个间隔的连线,如,今天的点连接明天的点

   NSArray *ktempArray = [selfchangeKPointWithData:getdata.data];//换算成实际每天收盘价坐标数组

   lines *kline = [[linesalloc]initWithFrame:CGRectMake(0,0,mainboxView.frame.size.width,mainboxView.frame.size.height)];

    kline.points = ktempArray;

    kline.lineWidth =self.kLineWidth;

    kline.isK =YES;

    [mainboxViewaddSubview:kline];

    [lineArrayaddObject:kline];

    

    //在成交量视图左右下方显示开始和结束日期

    NSString *tempStr1 =[[getdata.dataobjectAtIndex:0]objectAtIndex:0];

    startDateLab.text = [NSStringstringWithFormat:@"%@-%@-%@",[tempStr1substringWithRange:NSMakeRange (0,4)],[tempStr1substringWithRange:NSMakeRange (4,2)],[tempStr1substringWithRange:NSMakeRange (6,2)]];

   NSString *tempStr2 = [[getdata.dataobjectAtIndex:getdata.data.count-1]objectAtIndex:0];

    endDateLab.text = [NSStringstringWithFormat:@"%@-%@-%@",[tempStr2substringWithRange:NSMakeRange (0,4)],[tempStr2substringWithRange:NSMakeRange (4,2)],[tempStr2substringWithRange:NSMakeRange (6,2)]];


    // 开始画连成交量

   NSArray *voltempArray = [selfchangeVolumePointWithData:getdata.data];//换算成实际成交量坐标数组

    //NSLog(@"voltempArray:%@",voltempArray);

   lines *volline = [[linesalloc]initWithFrame:CGRectMake(0,0,bottomBoxView.frame.size.width,bottomBoxView.frame.size.height)];

    volline.points = voltempArray;

    volline.lineWidth =self.kLineWidth;

    volline.isK =YES;

    volline.isVol =YES;

    [bottomBoxViewaddSubview:volline];

    shou1.text = [commondchangePrice:getdata.volMaxValue];

    shou2.text = [commondchangePrice:getdata.volMaxValue/3*2];

    shou3.text = [commondchangePrice:getdata.volMaxValue/3];

    [lineArrayaddObject:volline];

}


#pragma mark 画各种均线

-(void)drawMAWithIndex:(int)index andColor:(NSString*)color{

   NSArray *tempArray = [selfchangePointWithData:getdata.dataandMA:index];// 换算成实际坐标数组

   lines *line = [[linesalloc]initWithFrame:CGRectMake(0,0,mainboxView.frame.size.width,mainboxView.frame.size.height)];

    line.color = color;

    line.points = tempArray;

    //NSLog(@"date:%d",_date());

    line.isK =NO;

    [mainboxViewaddSubview:line];

    [lineArrayaddObject:line];

}


#pragma mark 把股市数据换算成实际的点坐标数组

-(NSArray*)changeKPointWithData:(NSArray*)data{

    NSMutableArray *tempArray = [[NSMutableArrayalloc]init];

   pointArray = [[NSMutableArrayalloc]init];

   CGFloat PointStartX =self.kLineWidth/2;//起始点坐标

    //NSLog(@"date:%@",data);

   for (NSArray *itemin data) {

        CGFloat heightvalue = [[itemobjectAtIndex:2]floatValue];// 得到最高价

       CGFloat lowvalue = [[itemobjectAtIndex:3]floatValue];// 得到最低价

       CGFloat openvalue = [[itemobjectAtIndex:1]floatValue];// 得到开盘价

       CGFloat closevalue = [[itemobjectAtIndex:4]floatValue];// 得到收盘价

        CGFloat yHeight =getdata.maxValue -getdata.minValue ;// y的价格高度

       CGFloat yViewHeight =mainboxView.frame.size.height ;// y的实际像素高度

        // 换算成实际的坐标

       CGFloat heightPointY = yViewHeight * (1 - (heightvalue -getdata.minValue) / yHeight);

       CGPoint heightPoint = CGPointMake(PointStartX, heightPointY); // 最高价换算为实际坐标值

       CGFloat lowPointY = yViewHeight * (1 - (lowvalue -getdata.minValue) / yHeight);;

       CGPoint lowPoint = CGPointMake(PointStartX, lowPointY); // 最低价换算为实际坐标值

       CGFloat openPointY = yViewHeight * (1 - (openvalue -getdata.minValue) / yHeight);;

       CGPoint openPoint = CGPointMake(PointStartX, openPointY); // 开盘价换算为实际坐标值

       CGFloat closePointY = yViewHeight * (1 - (closevalue -getdata.minValue) / yHeight);;

       CGPoint closePoint = CGPointMake(PointStartX, closePointY); // 收盘价换算为实际坐标值

        // 实际坐标组装为数组

       NSArray *currentArray = [[NSArrayalloc]initWithObjects:

                                NSStringFromCGPoint(heightPoint),

                                NSStringFromCGPoint(lowPoint),

                                NSStringFromCGPoint(openPoint),

                                NSStringFromCGPoint(closePoint),

                                 [itemobjectAtIndex:0],//保存日期时间

                                 [itemobjectAtIndex:4],//收盘价

                                 [itemobjectAtIndex:7],// MA5

                                 [itemobjectAtIndex:8],// MA10

                                 [itemobjectAtIndex:9],// MA20

                                 [itemobjectAtIndex:2],//最高价

                                 [itemobjectAtIndex:3],//最低价

                                 [itemobjectAtIndex:1],//开盘价

                                 [itemobjectAtIndex:5],//成交量

                                 [itemobjectAtIndex:6],//成交金额

                                 

                                nil];

        [tempArrayaddObject:currentArray];// 把坐标添加进新数组

        currentArray =Nil;

        PointStartX +=self.kLineWidth+self.kLinePadding;//生成下一个点的x

        

    }

   pointArray = tempArray;

   return tempArray;

}


#pragma mark 把股市数据换算成实际的点坐标数组 

-(NSArray*)changePointWithData:(NSArray*)data  andMA:(int)MAIndex{

    NSMutableArray *tempArray = [[NSMutableArrayalloc]init];

   CGFloat PointStartX =0.0f; // 起始点坐标

   for (NSArray *itemin data) {

       CGFloat currentValue = [[itemobjectAtIndex:MAIndex] floatValue];//得到均价价格

        // 换算成实际的坐标

       CGFloat currentPointY =mainboxView.frame.size.height - ((currentValue -getdata.minValue) / (getdata.maxValue -getdata.minValue) *mainboxView.frame.size.height);

       CGPoint currentPoint = CGPointMake(PointStartX, currentPointY); // 换算到当前的坐标值

        [tempArrayaddObject:NSStringFromCGPoint(currentPoint)];//把坐标添加进新数组

        PointStartX +=self.kLineWidth+self.kLinePadding;//生成下一个点的x

    }

   return tempArray;

}


#pragma mark 把股市数据换算成成交量的实际坐标数组

-(NSArray*)changeVolumePointWithData:(NSArray*)data{

    NSMutableArray *tempArray = [[NSMutableArrayalloc]init];

   CGFloat PointStartX =self.kLineWidth/2;//起始点坐标

   for (NSArray *itemin data) {

       CGFloat volumevalue = [[itemobjectAtIndex:5]floatValue];// 得到每份成交量

        CGFloat yHeight =getdata.volMaxValue -getdata.volMinValue ;// y的价格高度

       CGFloat yViewHeight =bottomBoxView.frame.size.height ;// y的实际像素高度

        // 换算成实际的坐标

       CGFloat volumePointY = yViewHeight * (1 - (volumevalue -getdata.volMinValue) / yHeight);

       CGPoint volumePoint = CGPointMake(PointStartX, volumePointY); // 成交量换算为实际坐标值

       CGPoint volumePointStart =CGPointMake(PointStartX, yViewHeight);

        //把开盘价收盘价放进去好计算实体的颜色

       CGFloat openvalue = [[itemobjectAtIndex:1]floatValue];// 得到开盘价

       CGFloat closevalue = [[itemobjectAtIndex:4]floatValue];// 得到收盘价

       CGPoint openPoint = CGPointMake(PointStartX, closevalue); // 开盘价换算为实际坐标值

       CGPoint closePoint = CGPointMake(PointStartX, openvalue); // 收盘价换算为实际坐标值

        

        

        // 实际坐标组装为数组

       NSArray *currentArray = [[NSArrayalloc]initWithObjects:

                                NSStringFromCGPoint(volumePointStart),

                                NSStringFromCGPoint(volumePoint),

                                NSStringFromCGPoint(openPoint),

                                NSStringFromCGPoint(closePoint),

                                nil];

        [tempArrayaddObject:currentArray];// 把坐标添加进新数组

        currentArray =Nil;

        PointStartX +=self.kLineWidth+self.kLinePadding;//生成下一个点的x

        

    }

   // NSLog(@"处理完成");

    

   return tempArray;

}


#pragma mark 手指捏合动作

-(void)touchBoxAction:(UIPinchGestureRecognizer*)pGesture{

   isPinch  =NO;

    //NSLog(@"状态:%li==%f",(long)pinchGesture.state,pGesture.scale);

   if (pGesture.state==2 &&isUpdateFinish) {

       if (pGesture.scale>1) {

           //放大手势

           self.kLineWidth ++;

            [selfupdateSelf];

        }else{

           //缩小手势

           self.kLineWidth --;

            [selfupdateSelf];

        }

    }

   if (pGesture.state==3) {

        isUpdateFinish =YES;

    }

}

 //缩小手势,放大手势

-(void)updateSelf{

    if (isUpdateFinish) {

       if (self.kLineWidth>20)

           self.kLineWidth =20;

       if (self.kLineWidth<1)

           self.kLineWidth =1;

        isUpdateFinish =NO;

       isUpdate =YES;

       self.data =nil;

       pointArray =nil;

       if (!thread.isCancelled) {

            [threadcancel];

        }

        self.clearsContextBeforeDrawing =YES;

        [threadcancel];

       thread = [[NSThreadalloc]initWithTarget:selfselector:@selector(drawLine)object:nil];

        [threadstart];

        

    }

}


#pragma mark 长按就开始生成十字线

-(void)gestureRecognizerHandle:(UILongPressGestureRecognizer*)longResture{

   isPinch =YES;

    //NSLog(@"gestureRecognizerHandle%li",(long)longResture.state);

    touchViewPoint = [longResturelocationInView:mainboxView];

    //手指长按开始时更新一般

    if(longResture.state ==UIGestureRecognizerStateBegan){

        [selfupdate];

    }

    //手指移动时候开始显示十字线

    if (longResture.state ==UIGestureRecognizerStateChanged) {

        [selfisKPointWithPoint:touchViewPoint];

    }

    

    //手指离开的时候移除十字线

    if (longResture.state ==UIGestureRecognizerStateEnded) {

        [movelineoneremoveFromSuperview];

        [movelinetworemoveFromSuperview];

        [xxViewremoveFromSuperview];

        [movelinetwoLableremoveFromSuperview];

        

       movelineone =nil;

       movelinetwo =nil;

       xxView =nil;

        movelinetwoLable =nil;

       isPinch =NO;

    }

}


#pragma mark 判断并在十字线上显示提示信息

-(void)isKPointWithPoint:(CGPoint)point{

   CGFloat itemPointX =0;

   for (NSArray *iteminpointArray) {

        //NSLog(@"item:%@",item);


       CGPoint itemPoint =CGPointFromString([item objectAtIndex:0]); //收盘价的坐标

        itemPointX = itemPoint.x;

       int itemX = (int)itemPointX;

       int pointX = (int)point.x;

       if (itemX==pointX || point.x-itemX<=self.kLineWidth/2) {

            movelineone.frame =CGRectMake(itemPointX,movelineone.frame.origin.y,movelineone.frame.size.width,movelineone.frame.size.height);

            movelinetwo.frame =CGRectMake(movelinetwo.frame.origin.x,itemPoint.y,movelinetwo.frame.size.width,movelinetwo.frame.size.height);

           //垂直提示成交价格

           NSString *tempStr =[itemobjectAtIndex:4];

            riqLable.text = [NSStringstringWithFormat:@"%@-%@-%@",[tempStrsubstringWithRange:NSMakeRange (0,4)],[tempStrsubstringWithRange:NSMakeRange (4,2)],[tempStrsubstringWithRange:NSMakeRange (6,2)]];//日期

           kpLable.text =[NSStringstringWithFormat:@"开盘:%@",[itemobjectAtIndex:11]];

           zgLable.text =[NSStringstringWithFormat:@"最高:%@",[itemobjectAtIndex:9]];

           zdLable.text =[NSStringstringWithFormat:@"最低:%@",[itemobjectAtIndex:10]];

           spLable.text =[NSStringstringWithFormat:@"收盘:%@",[itemobjectAtIndex:5]];

            cjlLable.text =[NSStringstringWithFormat:@"成交量:%@",[commondchangePrice:[[itemobjectAtIndex:12]floatValue]]];

            cjeLable.text =[NSStringstringWithFormat:@"成交额:%@",[commondchangePrice:[[itemobjectAtIndex:13]floatValue]]];

            zflLable.text =[NSStringstringWithFormat:@"涨幅:%.2f%%",([[itemobjectAtIndex:5]floatValue]-[[itemobjectAtIndex:11]floatValue])/[[itemobjectAtIndex:11]floatValue]*100];

           CGFloat oneLableY =bottomBoxView.frame.origin.y;

           CGFloat oneLableX =0;

           if (itemPointX<xxView.frame.size.width/2) {

                oneLableX =xxView.frame.size.width/2 - itemPointX;

            }

           if ((mainboxView.frame.size.width - itemPointX)<xxView.frame.size.width/2) {

                oneLableX = -(xxView.frame.size.width/2 - (mainboxView.frame.size.width - itemPointX));

            }

           xxView.frame =CGRectMake(itemPointX -xxView.frame.size.width/2 + oneLableX, oneLableY,

                                               xxView.frame.size.width,xxView.frame.size.height);

            

             //NSLog(@"item:%@",item);

           //横向提示成交数量

           movelinetwoLable.text = [itemobjectAtIndex:5];//

           CGFloat twoLableX =movelinetwoLable.frame.origin.x;

            //如果滑动到了左半边则提示向右跳转

           if ((mainboxView.frame.size.width - itemPointX) >mainboxView.frame.size.width/2) {

                twoLableX =mainboxView.frame.size.width -movelinetwoLable.frame.size.width;

            }else{

                twoLableX =0;

            }

           movelinetwoLable.frame =CGRectMake(twoLableX,itemPoint.y -movelinetwoLable.frame.size.height/2 ,

                                               movelinetwoLable.frame.size.width,movelinetwoLable.frame.size.height);

            

         

           break;

        }

    }

    

}


-(void)update{

    if (self.kLineWidth>20)

       self.kLineWidth =20;

    if (self.kLineWidth<1)

       self.kLineWidth =1;

   isUpdate =YES;

   if (!thread.isCancelled) {

        [threadcancel];

    }

    self.clearsContextBeforeDrawing =YES;


    [threadcancel];

    thread = [[NSThreadalloc]initWithTarget:selfselector:@selector(drawLine)object:nil];

    [threadstart];

    

}



-(void)dealloc{

   thread =nil;

}


@end


#import <Foundation/Foundation.h>


@interface getData :NSObject

@property (nonatomic,retain)NSMutableArray *data;

@property (nonatomic,retain)NSArray *dayDatas;

@property (nonatomic,retain)NSMutableArray *category;

@property (nonatomic,retain)NSString *lastTime;

@property (nonatomic,retain)UILabel *status;

@property (nonatomic,assign)BOOL isFinish;

@property (nonatomic,assign)CGFloat maxValue;

@property (nonatomic,assign)CGFloat minValue;

@property (nonatomic,assign)CGFloat volMaxValue;

@property (nonatomic,assign)CGFloat volMinValue;

@property (nonatomic,assign)NSInteger kCount;

@property (nonatomic,retain)NSString *req_type;



-(void)changeFSData:(NSArray*)lines;

-(void)changeRKData:(NSArray*)lines;


@end


#import "getData.h"

#import "commond.h"


@implementation getData


-(id)init{

   self = [superinit];

   if (self){

       self.isFinish =NO;

       self.maxValue =0;

       self.minValue =CGFLOAT_MAX;

       self.volMaxValue =0;

       self.volMinValue =CGFLOAT_MAX;

    }

    return  self;

}


//解析具体数据并赋值组合

-(void)changeFSData:(NSArray*)lines{

    NSMutableArray *data =[[NSMutableArrayalloc]init];

//NSMutableArray *category =[[NSMutableArray alloc] init];

   NSArray *newArray = lines;

    newArray = [newArrayobjectsAtIndexes:[[NSIndexSetalloc]initWithIndexesInRange:NSMakeRange(0,self.kCount>=newArray.count?newArray.count:self.kCount)]];//只要前面指定的数据

   

   NSInteger idx;


   for (idx =0; idx < newArray.count; idx++) {

        

       if (idx >0)

        {

           NSString *bfLine = [newArrayobjectAtIndex:idx-1];//前面一个数组

           NSString *line = [newArrayobjectAtIndex:idx];

           if([lineisEqualToString:@""]){

               continue;

            }

            NSArray   *bfArr = [bfLinecomponentsSeparatedByCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@","]];

            NSArray   *arr = [linecomponentsSeparatedByCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@","]];

            

            // 收盘价的最小值和最大值

           if ([[arrobjectAtIndex:1]floatValue]>self.maxValue) {

               self.maxValue = [[arrobjectAtIndex:1]floatValue];

            }

           if ([[arrobjectAtIndex:1]floatValue]<self.minValue) {

               self.minValue = [[arrobjectAtIndex:1]floatValue];

            }

            

           float crtVol = [[arrobjectAtIndex:2]floatValue] - [[bfArr objectAtIndex:2]floatValue];//当前累加的数据减去上一个得到成交量

             //NSLog(@"crtVol:%.2f",crtVol);

            // 成交量的最大值最小值

           if (crtVol>self.volMaxValue) {

               self.volMaxValue = crtVol;

            }

           if (crtVol<self.volMinValue) {

               self.volMinValue = crtVol;

            }

            NSMutableArray *item =[[NSMutableArrayalloc]init];

            

            [itemaddObject:[arrobjectAtIndex:0]];//成交均价

            [itemaddObject:[arrobjectAtIndex:1]];//成交价格

            [itemaddObject:[NSStringstringWithFormat:@"%.0f",crtVol]];//成交数量

            [itemaddObject:[arrobjectAtIndex:3]];//成交金额

            

            [dataaddObject:item];//组合总data

 

        }

       else{

           NSString *line = [newArrayobjectAtIndex:idx];

           if([lineisEqualToString:@""]){

               continue;

            }

            NSArray   *arr = [linecomponentsSeparatedByCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@","]];

            // 收盘价的最小值和最大值

           if ([[arrobjectAtIndex:1]floatValue]>self.maxValue) {

               self.maxValue = [[arrobjectAtIndex:1]floatValue];

            }

           if ([[arrobjectAtIndex:1]floatValue]<self.minValue) {

               self.minValue = [[arrobjectAtIndex:1]floatValue];

            }

            // 成交量的最大值最小值

           if ([[arrobjectAtIndex:2]floatValue]>self.volMaxValue) {

               self.volMaxValue = [[arrobjectAtIndex:2]floatValue];

                //NSLog(@"volMaxValue:%f",self.volMaxValue);

            }

           if ([[arrobjectAtIndex:2]floatValue]<self.volMinValue) {

               self.volMinValue = [[arrobjectAtIndex:2]floatValue];

                //NSLog(@"volMinValue:%f",self.volMinValue);

            }

            NSMutableArray *item =[[NSMutableArrayalloc]init];

            

            [itemaddObject:[arrobjectAtIndex:0]];//成交均价

            [itemaddObject:[arrobjectAtIndex:1]];//成交价格

            [itemaddObject:[arrobjectAtIndex:2]];//成交数量

            [itemaddObject:[arrobjectAtIndex:3]];//成交金额

            

            

            [dataaddObject:item];//组合总data

            

            //NSLog(@"self.volMaxValue:%.2f",self.volMaxValue);


        }

        

    }

    

    

     //NSLog(@"data:%@",data);

if(data.count==0){

self.status.text = @"Error!";

   return;

}

    

   self.data = data;

}


-(void)changeRKData:(NSArray*)lines{

    NSMutableArray *data =[[NSMutableArrayalloc]init];

   NSArray *newArray = lines;

    newArray = [newArrayobjectsAtIndexes:[[NSIndexSetalloc]initWithIndexesInRange:NSMakeRange(0,self.kCount>=newArray.count?newArray.count:self.kCount)]];//只要前面指定的数据

    

   NSInteger idx;

   int MA5=5,MA10=10,MA20=20;//均线统计

   for (idx = newArray.count-1; idx >=0; idx--) {

        

       NSString *line = [newArrayobjectAtIndex:idx];

       if([lineisEqualToString:@""]){

           continue;

        }

        NSArray   *arr = [linecomponentsSeparatedByCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@","]];

        // 收盘价的最小值和最大值

       if ([[arrobjectAtIndex:4]floatValue]>self.maxValue) {

           self.maxValue = [[arrobjectAtIndex:4]floatValue];

        }

       if ([[arrobjectAtIndex:4]floatValue]<self.minValue) {

           self.minValue = [[arrobjectAtIndex:4]floatValue];

        }

        // 成交量的最大值最小值

       if ([[arrobjectAtIndex:5]floatValue]>self.volMaxValue) {

           self.volMaxValue = [[arrobjectAtIndex:5]floatValue];

            //NSLog(@"volMaxValue:%f",self.volMaxValue);

        }

       if ([[arrobjectAtIndex:5]floatValue]<self.volMinValue) {

           self.volMinValue = [[arrobjectAtIndex:5]floatValue];

            //NSLog(@"volMinValue:%f",self.volMinValue);

        }

        NSMutableArray *item =[[NSMutableArrayalloc]init];

        

        [itemaddObject:[arrobjectAtIndex:0]];//日期

        [itemaddObject:[arrobjectAtIndex:1]];//今日开盘

        [itemaddObject:[arrobjectAtIndex:2]];//最高成交

        [itemaddObject:[arrobjectAtIndex:3]];//最低成交

        [itemaddObject:[arrobjectAtIndex:4]];//最近成交

        [itemaddObject:[arrobjectAtIndex:5]];//成交数量

        [itemaddObject:[arrobjectAtIndex:6]];//成交金额

        

       CGFloat idxLocation = [linesindexOfObject:line];

       // MA5

        [itemaddObject:[NSNumbernumberWithFloat:[selfsumArrayWithData:linesandRange:NSMakeRange(idxLocation, MA5)]]];//前五日收盘价平均值

       // MA10

        [itemaddObject:[NSNumbernumberWithFloat:[selfsumArrayWithData:linesandRange:NSMakeRange(idxLocation, MA10)]]];//前十日收盘价平均值

       // MA20

        [itemaddObject:[NSNumbernumberWithFloat:[selfsumArrayWithData:linesandRange:NSMakeRange(idxLocation, MA20)]]];//前二十日收盘价平均值

        

        [dataaddObject:item];//组合总data

        

    }

    //NSLog(@"data:%@",data);

   if(data.count==0){

       self.status.text =@"Error!";

       return;

    }

    

   self.data = data;

}



-(CGFloat)sumArrayWithData:(NSArray*)data andRange:(NSRange)range{

   CGFloat value =0;

   if (data.count - range.location>range.length) {

        NSArray *newArray = [dataobjectsAtIndexes:[[NSIndexSetalloc]initWithIndexesInRange:range]];

       for (NSString *itemin newArray) {

            NSArray *arr = [itemcomponentsSeparatedByCharactersInSet:[NSCharacterSetcharacterSetWithCharactersInString:@","]];

            value += [[arrobjectAtIndex:4]floatValue];//最近成交

        }

       if (value>0) {

            value = value/ newArray.count;

        }

    }

   return value;

}


@end


实现效果如图:




尊重知识,赞赏199元,并留下邮箱,将发整个源码,你的支持是我的动力。


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/45637.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【ChatGPT里的平行宇宙

除非你一直生活在岩石下&#xff0c;否则你肯定听说过ChatGP。 你可能知道它在解决 IQ 测试、解决 leetcode 问题或帮助人们编写 LateX 方面的能力。 它是人们检索各种信息和解决繁琐任务&#xff08;如文案写作&#xff09;的绝佳资源&#xff01; 今天&#xff0c;Frederic …

AIGC将颠覆设计界?!今晚直播间解密AIGC之图像生成史

从DeepFake、风格迁移到 Midjourney、DALLE ... AIGC的应用一次又一次带给我们惊喜 这些背后的蕴藏着哪些原理&#xff1f; 赶快加入AIGC图像生成直播课&#xff01; 探索AI生成艺术的奥秘 2月28日-3月7日每周二晚8点 系列直播课「扫码报名」啦&#xff01; 扫描下方二维码&…

chatgpt赋能python:Python导入照片的SEO优化指南

Python导入照片的SEO优化指南 在当今的数字时代&#xff0c;网站的视觉效果已经成为重要的一环。而在网站上展示照片既可以吸引用户的眼球&#xff0c;又可以更好地传达信息。然而&#xff0c;对于搜索引擎来说&#xff0c;照片是无法读懂的&#xff0c;它们需要依靠一些描述性…

chatgpt赋能python:Python怎么导入照片

Python怎么导入照片 Python是一种高级编程语言&#xff0c;可用于创建各种应用程序和项目。当涉及到处理图像时&#xff0c;Python也非常有用。在本文中&#xff0c;我们将介绍如何使用Python导入照片&#xff0c;并附带一些有关如何使用SEO优化您的图像的提示。 介绍 在开始…

作曲 app android,文艺又好玩!安卓作曲达人App试用体验

说起文艺&#xff0c;自然是离不开琴棋书画。喜欢文艺的机友为数不少&#xff0c;安卓平台也有不少关于琴棋书画的App。今天要介绍的这款安卓作曲达人App&#xff0c;可以说比它技术的没它文艺&#xff0c;比它文艺的没它技术。无论你懂不懂乐理&#xff0c;看着一个个音符在你…

妙计高招:短信验证码接收教程图像处理AI黑科技汇总

随着人工智能技术的越来越火爆&#xff0c;我们在使用国内外应用提供的功能时经常会用到短信验证功能&#xff0c;对于我们而言&#xff0c;轻松搞好短信验证没有那么容易&#xff0c;本篇文章对几篇接收验证码的教程进行了汇总并附带了一些主流AI软件的使用教程&#xff0c;希…

ChatGPT真的泰酷啦!泰酷啦!

马总来中国啦&#xff01;最近chatGPT有多火&#xff0c;就不用我多说了。。。 真的佩服Musk&#xff0c;其公司的产品每个都能出圈&#xff0c;虽然OpenAI只是他投的一个项目&#xff0c;但总感觉吸了他欧气的项目就总能火。就看会不会被twitter砸了招牌。但即便twitter垮了&a…

尝试使用chatgpt帮我优化sql

尝试写一些sql看看chatgpt写的和自己写的哪里不一样&#xff0c;帮助我打开思路。 第一题 数据库中有个员工表emp,建表语句如下: create table emp_his (emp_id number, emp_name varchar(50)); 表中存在重复记录(根据emp_id来判断),用SQL如何查出存在重复的 emp_id&#xff…

java 大结果_java三大工厂结果总览

2018-11-02 21:27:18 开始写 谢谢、Thank you、Salamat Do(撒拉玛特朵)、あリがCm o*n(嘉蒙)とゥ(阿里嘎都)、????? (勘三哈咪瘩)、terima Kasih(得力马卡系)、kob-khun(寇布库恩)、dhanyavaad(达尼阿瓦德)、toda(透达)、te?ekkr ederim(特谢库尔埃戴里姆)、Dzie,kuje(以…

[教师资格证-中学笔试-裸考过关]教育知识与能力必背知识点(技巧)

裸考过了综测和专业课&#xff0c;都是刚刚达线&#xff0c;而教育知识与常识需要背&#xff0c;所以68分没过。。。很惨.。。就差了一个选择题。 所以再次考试的时候还是准备了下&#xff0c;至少得看看考什么&#xff0c;不然真的太惨了&#xff0c;68.。。。不过其他两门裸考…

搭载鸿蒙os的电脑,全新华为 MatePad Pro 发布在即:搭载鸿蒙系统

华为宣布将于 6 月 2 日晚 8 时举行线上发布会&#xff0c;将正式发布可以覆盖手机&#xff0c;手表&#xff0c;平板等移动终端的鸿蒙操作系统。华为全新的平板产品华为 MatePad Pro 也将在此次发布会上亮相&#xff0c;这款新平板也将全面搭载鸿蒙操作系统&#xff0c;它也将…

ajax 皇马,历史上最伟大11支球队 西班牙国家队在列 皇马两次入选

导读&#xff1a;历史上最伟大11支球队 西班牙国家队在列 皇马两次入选 各位点开这篇文章的朋友们&#xff0c;想必都是很高的颜值吧&#xff0c;我们真的是很有缘哦&#xff0c;小编每天都会给大家带来不一样的体育资讯&#xff0c;如果对小编的文章或者其他的什么&#xff0c…

1500_1763 全球统一 伊比利亚 俄罗斯 西欧

1500~1763 全球统一 伊比利亚 俄罗斯 西欧 全球统一 1500~1763 1763&#xff0c;欧洲人已探明世界上大部分的海岸线&#xff0c;洲际贸易规模巨大&#xff0c;种族隔离被打破&#xff0c;一半非洲人离开非洲&#xff0c;动植物随之混合 亚洲由于足够强大且物资充沛&#xff…

Python注释以及快捷键

1、单行注释 单行注释是 # Mac的快捷键是 command/ windows的快捷键是 Ctrl / 2、多行注释 多行注释是三个单引号 注释 因为这个字符串没有名字&#xff0c;而且程序对这个字符串不做任何处理&#xff0c;所以它对程序的运行没有任何影响。它相当于一个注释&#xff0c;尽…

印章生成工具类开发

Java代码见我的资源 免费使用印章生成工具类&#xff0c;Java开发-Java文档类资源-CSDN下载印章生成工具类&#xff0c;Java开发更多下载资源、学习资料请访问CSDN下载频道.https://download.csdn.net/download/jlonghou/85218149代码&#xff1a; pom <?xml version"…

鲁祥老师吉他课学习笔记

鲁祥老师吉他课学习笔记 导语 参考教材&#xff1a; 《吉他入门经典教程》李国标 《弹指之间》潘尚文 《吉他教本》好连得出版社 《吉他教程》杰瑞吉他学校 《伯克利现代吉他教程》 《吉他考级教程》英国RSL其中的原声吉他和电吉他教程 《一个月电吉他新手养成计划》宫胁俊郎 …

谋定菲律宾农业全产业链建设 对话国际农民丰收节贸易会

谋定菲律宾农业全产业链建设 对话国际农民丰收节贸易会 新闻中国采编网 中国新闻采编网 谋定研究中国智库网 经信研究 国研智库 国情讲坛 哲商对话 万权采编&#xff1a;应菲律宾驻中国大使馆商务参赞格伦.佩尼亚兰达邀请&#xff0c;AIF亚投联代表团同菲律宾BOI在菲律宾马卡提…

因果解释能够对规则进行解释吗?

来源&#xff1a;《哲学动态》2017年第10期作者&#xff1a;初维峰&#xff08;西安交通大学人文社会科学学院&#xff09; 本文受中国博士后科学基金面上资助项目“当代西方因果解释理论研究”(2017M613160)资助。 在现实生活中&#xff0c;我们不仅要对某一事件进行解释&…

Cocos技术派 | 3d人物渲染详细教程

文章目录 前言3d系统基础FBX模型导入配置模型参数相机分组2D相机设置添加UI节点添加3D节点设置灯光设置平台接收阴影设置3D相机3D场景编辑器设置模型材质设置模型产生阴影设置相机位置播放动画增加3D动作 本文假设你是一个新手&#xff0c;按照本文的操作&#xff0c;可以跑起来…