2010-05-21 7 views
0

UIScrollView의 UIView에 그리드를 그리려합니다. UIView의 너비는 약 1000 픽셀입니다. 그러나, 나는 UIView의 처음 340 픽셀에 대해서만 줄을 그릴 수 있습니다. 아무도 이것에 나를 도울 수 있습니까?UIView의 절반 만 그릴 수 있습니다.

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 

CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 

waveScrollView = [[WaveScrollView alloc] initWithFrame:frame]; 

CGRect waveframe = CGRectMake(0, 0, 25 * 5 * 10, (10 * 2 + 10) * 12); 

EKGWaveView *ekgWaveView = [[EKGWaveView alloc] initWithFrame:waveframe]; 

waveScrollView.contentSize = CGSizeMake(waveframe.size.width, waveframe.size.height); 
waveScrollView.maximumZoomScale = 4.0; 
waveScrollView.minimumZoomScale = 0.75; 
waveScrollView.clipsToBounds = YES; 

waveScrollView.aView = ekgWaveView; 

[waveScrollView addSubview:ekgWaveView]; 

waveScrollView.delegate = self; 

[self.view addSubview:waveScrollView]; 
} 

내가 어떤 도움을 주셔서 감사합니다 다음과 같이 나 또한있는 UIScrollView와 UIView의를 설정하고

- (void)drawRect:(CGRect)rect 
{ 
NSInteger width = 25 * 5 * 10; 
NSInteger height = (10 * 2 + 10) * 12; 
NSInteger i; 

//Get the CGContext from this view 
CGContextRef context = UIGraphicsGetCurrentContext(); 

// Draw rectangle with a blue stroke color and white fill color 
CGContextSetRGBStrokeColor(context, 0.0, 0.0, 1.0, 1.0); 
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0); 
CGContextSetLineWidth(context, 2.0); 
CGContextAddRect(context, CGRectMake(0.0, 0.0, width, height)); 
CGContextFillPath(context); 

// Draw grid with red color 
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); 

// Set the width of the pen mark 
CGContextSetLineWidth(context, 0.2); 

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

    if (i % 25 == 0) 
    { 
     CGContextSetLineWidth(context, 0.4); 

     // Draw a line 
     CGContextMoveToPoint(context, i, 0.0); 
     CGContextAddLineToPoint(context, i, width); 
     CGContextStrokePath(context); 

     CGContextSetLineWidth(context, 0.2); 
    } 
    else 
    { 
     // Draw a line 
     CGContextMoveToPoint(context, i, 0.0); 
     CGContextAddLineToPoint(context, i, width); 
     CGContextStrokePath(context);  
    } 

} 

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

    if (i % 25 == 0) 
    { 
     CGContextSetLineWidth(context, 0.4); 

     // Draw a line 
     CGContextMoveToPoint(context, 0.0, i); 
     CGContextAddLineToPoint(context, height, i); 
     CGContextStrokePath(context); 

     CGContextSetLineWidth(context, 0.2); 
    } 
    else 
    { 
     // Draw a line 
     CGContextMoveToPoint(context, 0.0, i); 
     CGContextAddLineToPoint(context, height, i); 
     CGContextStrokePath(context); 
    } 

}  

} 

drawGrid 기능입니다. 감사.

답변

1

나는 당신이 몇 가지 변수를 섞어 왔음을 확신한다.

당신은 height 0에서 i을 반복하고 있지만 라인을 생성하고 y 매개 변수로 width를 사용할 때 당신은 당신 x 매개 변수로 i을 사용하고

.

관련 문제