0

UIViewで(画像をリンクするなど)画像ビューの間に線を引きたい。利用した

CGContextRef context    = UIGraphicsGetCurrentContext();

CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);

CGContextSetLineWidth(context, 2.0);

CGContextMoveToPoint(context, 0,0); //start at this point

CGContextAddLineToPoint(context, 20, 20); //draw to this point

CGContextStrokePath(context);

しかし、ここでは、私のコンテキストは null です。フレームワークをインポートする必要があるか、ヘッダーをインポートする必要があるかどうかはわかりません。提案やサンプルをいただければ幸いです。

前もって感謝します。

4

3 に答える 3

1

非常に簡単な方法は、高さ 1 のラベルを使用することです:)

UILabel *seperator=[[UILabel alloc]initWithFrame:CGRectMake(0, 53, 233, 1)];
seperator.backgroundColor=[UIColor redColor];

[loginView addSubview:seperator];
于 2012-07-23T07:54:37.747 に答える
0
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
 CGContextSetLineWidth(context, 5.0); 
CGContextMoveToPoint(context, 90, 90.0); 
CGContextAddLineToPoint(context, 120.0, 150.0);
 CGContextStrokePath(context); 
于 2012-08-29T17:03:43.780 に答える
0
UIGraphicsBeginImageContext(image_signature.image.size);
[yourImageView.image drawInRect:CGRectMake(0, 0, yourImageView.image.size.width, yourImageView.image.size.height)]; 
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 2.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 0, 0);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), 20, 20);
CGContextStrokePath(UIGraphicsGetCurrentContext());
[yourImageView setImage:UIGraphicsGetImageFromCurrentImageContext()];
UIGraphicsEndImageContext();

...そして「yourImageView」は、線を引くイメージビューです。一番下の各上部のイメージビューに線を引くことをお勧めします。これはオプションです。

于 2012-07-23T07:52:14.937 に答える