// // AFView.m // animationFrame // // Created by pingshw on 14-5-27. // Copyright (c) 2014年 pingshw. All rights reserved. // #import "AFView.h" #import "AFDescribeObj.h" @interface CCView : UIView @end @implementation AFView { CGFloat w; CGFloat h; } @synthesize min_Y; @synthesize max_Y; @synthesize min_X; @synthesize max_X; @synthesize data; @synthesize x_labels; @synthesize y_labels; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { w = frame.size.width; h = frame.size.height; //背景色 // self.backgroundColor = RQMianColor; } return self; } - (void)setData:(NSArray *)_data { data = [NSArray arrayWithArray:_data]; // NSString* imgName = @"question_index_bg.png"; CGFloat startTime = .5f; // UIImageView *iv; UIColor* lineCol = [UIColor whiteColor]; CGFloat imgw = 12; CGPoint e; UIView* ccv; if (_data.count >0) { e = [data[0] CGPointValue]; if (max_X == min_X) { //如果只有一个点 就把点放中间 e.x = w / 2.0; }else{ e.x = (e.x - min_X)*0.8*w/(max_X - min_X) + 0.125*w; } e.y = 0.875*h - (e.y - min_Y)*0.8*h/(max_Y - min_Y); ccv = [[CCView alloc] initWithFrame:CGRectMake(0, 0, imgw, imgw)]; [self addSubview:ccv]; ccv.center = e; } for (int i=1; i