2012-03-21 8 views
0

" - (void)drawRect :(CGRect)rect"メソッド内のUIViewにあります。 普通の黒い線(境界線として)を描きたいのですが、私はいつも半透明の線を描いています。 コーナーの4点のみ完全に黒です。 なぜですか?ここで プレーンな(非透明な)線を描くには?

がmycodeです:あなたはUIViewのに境界線を追加したい場合は

- (void)drawRect:(CGRect)rect 
{ 
CGContextRef context = UIGraphicsGetCurrentContext(); 
CGContextSetAlpha(context,1.0); 
CGContextSetRGBStrokeColor(context,0.0,0.0,0.0,1.0); 
CGContextMoveToPoint(context,0.0,0.0); 
CGContextAddLineToPoint(context,rect.size.width,0.0); 
CGContextAddLineToPoint(context,rect.size.width,rect.size.height); 
CGContextAddLineToPoint(context,0.0,rect.size.height); 
CGContextClosePath(context); 
CGContextStrokePath(context); 
} 

答えて

0

は、あなたにも以下のようにそれを行うことができます

yourView.layer.borderColor = [UIColor blackColor].CGColor; 
yourView.layer.borderWidth = 2.0f; 

QuartzCoreフレームワークをインポートすることを忘れないでください。

関連する問題