2013-01-10 13 views
6

Mam drawRect i chcę wypełnić rect określony w określonym kolorze. Jak to zrobić? Do tej pory próbowałem następujące:jak mogę wypełnić drawRect w kolorze

- (void)drawRect:(CGRect)rect 
{ 
     CGContextRef context = UIGraphicsGetCurrentContext(); 
     CGContextSetFillColorWithColor(context, [UIColor colorWithWhite:29/255.f alpha:1.0].CGColor); 
CGContextFillRect(context, rect); 
} 

nie wydają się działać

+2

Zobacz ten link: http://stackoverflow.com/questions/2985359/how-to-fill-a-path-with-gradient-in-drawrect – Vishal

+0

Sprawdź również: http://stackoverflow.com/questions/3800278/iphone-draw-transparent- rectangle-on-uiview-to -reveal-view-under – Vishal

Odpowiedz

23
[[UIColor colorWithWhite:29/255.f alpha:1.0] setFill]; 
UIRectFill(rect); 

Jest to najprostszy sposób

Powiązane problemy