iphone上如何绘制点状图
2010-10-19 20:45:23 来源:WEB开发网先上效果图:
直接贴上完整的实现代码, 看不懂的地方自己google查询,学习。
CustomPolylineView.h
01//create by suruiqiang 10.10.8
02#import
03
04// 点状图
05@interface CustomPolylineView : UIView {
06
07 NSArray* dataSource;
08 NSMutableArray* dataSourceAfterPorcess;
09 float maxValue, minValue, averageScaleValue, columnWidth;
10 float standardValue;
11 int numberOfPlayedTimes,IntervalValue;
12 UIImage* ballImage;
13}
14@property(nonatomic, retain)NSArray* dataSource;
15@property(nonatomic, retain)NSMutableArray* dataSourceAfterPorcess;
16@property(nonatomic,assign)float standardValue;
17@end
CustomPolylineView.m
001//
002// CustomPolylineView.m
003// GolfSense
004//
005// Created by suruiqiang on 10/8/10.
006// Copyright 2010 __MyCompanyName__. All rights reserved.
007//
008
009#import "CustomPolylineView.h"
010#define MARGIN_LEFTSIDE 20
011#define MARGIN_BOTTOM_SIDE 20
012#define MARGIN_TOP_SIDE 10
013@interface CustomPolylineView(private)
014-(void)drawScale:(CGContextRef)context rect:(CGRect)_rect;
015-(void)calcScale:(CGRect)_rect;
016-(UIImage*)createImage;
017@end
018
019@implementation CustomPolylineView
020@synthesize dataSource;
021@synthesize dataSourceAfterPorcess;
022@synthesize standardValue;
023
024- (id)initWithFrame:(CGRect)frame {
025 if ((self = [super initWithFrame:frame])) {
026 // Initialization code
更多精彩
赞助商链接