objective c - iOS: Draw clear circle with UIBezierPath bezierPathWithOvalInRect: -
in uitableviewcontroller
's cells, want display circle number in it. using uibezierpath
's bezierpathwithovalinrect:
draw circle.
unfortunately, while can set fill
color clearcolor
, unused portion of cgrect
passed bezierpathwithovalinrect:
black.
how rid of black area created?
partial screenshot reference:
(i hope number inside circle)
code:
ltttableviewcell:
- (void)awakefromnib { [super awakefromnib]; // create square view using height of cell cgrect positionframe = cgrectmake(0, 0, self.bounds.size.height, self.bounds.size.height); lttdrawballview *drawballview = [[lttdrawballview alloc] initwithframe:positionframe]; [self.contentview addsubview:drawballview]; }
lttdrawballview:
- (void)drawrect:(cgrect)rect { // create new rect padding // + create circle new rect: cgrect box = cgrectinset(self.bounds, self.bounds.size.width * 0.1f, self.bounds.size.height * 0.1f); uibezierpath *ballbezierpath = [uibezierpath bezierpathwithovalinrect:box]; [[uicolor whitecolor] setstroke]; [[uicolor greencolor] setfill]; // green here show black area [ballbezierpath stroke]; [ballbezierpath fill]; [self setbackgroundcolor:[uicolor clearcolor]]; // happens , without line }
in init method of lttdrawballview, include code:
self.opaque = no; self.backgroundcolor = [uicolor clearcolor];
Comments
Post a Comment