WEB开发网
开发学院手机开发iPhone 开发 iphone上如何绘制点状图 阅读

iphone上如何绘制点状图

 2010-10-19 20:45:23 来源:WEB开发网   
核心提示:156 endPos = (i+1)*IntervalValue;157 }158 else159 {160 endPos = [dataSource count];161 }162163 for (int index=startPos; index<=endPos-1; ++index) {164 oneGro

156 endPos = (i+1)*IntervalValue;

157 }

158 else

159 {

160 endPos = [dataSource count];

161 }

162

163 for (int index=startPos; index<=endPos-1; ++index) {

164 oneGroupTotalValue += [[dataSource objectAtIndex:index] floatValue];

165 }

166

167 oneGroupAvageValue = oneGroupTotalValue/IntervalValue;

168 [dataSourceAfterPorcess addObject:[NSNumber numberWithFloat:oneGroupAvageValue]];

169 }

170}

171

172

173- (void)dealloc {

174 [super dealloc];

175}

176@end

177

178

179

180//-(UIImage*)createImage

181//{

182// CGSize size = CGSizeMake(32,32);

183// CGRect rect = CGRectMake(0, 0, 32, 32);

184// UIGraphicsBeginImageContext(size);

185// CGContextRef context = UIGraphicsGetCurrentContext();

186//

187// unsigned int red, green, blue;

188// // Fill color.

189// CGContextSetRGBFillColor(context, 0.7, 0.7, 0.7, 1.0);

190//

191// // Your drawing code.

192// CGContextFillEllipseInRect(context, rect);

193//

194// // Get the image and return.

195// UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

196// UIGraphicsEndImageContext();

197// return image;

198//}

调用处代码 *viewControler.m:

01CustomPolylineView* polyView = [[CustomPolylineView alloc] initWithFrame:CGRectMake(10,30, 200, 200)];

02NSArray* g = [NSArray arrayWithObjects:[NSNumber numberWithFloat:18.0],

03 [NSNumber numberWithFloat:21.0],

04 [NSNumber numberWithFloat:22.0],

05 [NSNumber numberWithFloat:32.0],

06 [NSNumber numberWithFloat:34.0],nil];

07

08polyView.dataSource = g;

09polyView.frame = CGRectOffset(polyView.frame, 0, 44);

10[self.view addSubview:polyView];

图上的紫色图片即可以使用代码生成,也可以直接使用图片。代码中已经将代码生成图片的代码注释掉

上一页  1 2 3 4 5 

Tags:iphone 如何 绘制

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接