2012-02-14 18 views
0

私はスタティックX、Y座標とのラインを入れたいが、私は、高さと(x、y)のから始まる垂直線を描画するには、いくつかの条件描画を使用してグラフを配置する方法は?

-(void)drawRect:(CGRect)rect 
{ 
    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate; 
    CGRect customPath1 = CGRectMake(35, 183, 10, delegate.breakFastTotalamt); 
    CGRect customPath2 = CGRectMake(140, 183, 10, 100); 
    UIBezierPath *path1 = [UIBezierPath bezierPathWithRect:customPath1]; 
    UIBezierPath *path2 = [UIBezierPath bezierPathWithRect:customPath2]; 
    [[UIColor greenColor]set]; 
    [path1 fill]; 
    [path2 fill]; 
} 
+0

それでは、どうしたのですか? –

+0

また、コードには2つの矩形しか表示されませんが、線も高さもありません。 – sch

+0

私は横長の幅でボタンで作られた水平線をつくっています。2.その線上で、私はウベジーザパスを使っていろいろな線を引いていきたいと思います。私はデータベースから高さの値を得ています。高さがそのボタンについている線を変えるときには、私はスタティックポイントを起動するだけで、高さは – Shreedhar

答えて

0

にaccoding高さを変更したいですあなたは次のようなことをすることができます:

UIBezierPath* path = [UIBezierPath bezierPath]; 
[path moveToPoint:CGPointMake(x, y)]; 
[path addLineToPoint:CGPointMake(x, y + h)]; 
[path closePath]; 
[[UIColor greenColor] setStroke]; 
path.lineWidth = 5; // Or whatever width you want 
[path stroke]; 
+0

でなければなりません。 [パスaddLineToPoint:CGPointMake(x、y-h)]; – Shreedhar

関連する問題