在我UITableViewController
的单元格中,我想显示一个带有数字的圆圈。我正在使用UIBezierPath
'sbezierPathWithOvalInRect:
来绘制圆圈。
不幸的是,虽然我可以将fill
颜色设置为,但传递给clearColor
的未使用部分是黑色。CGRect
bezierPathWithOvalInRect:
如何摆脱创建的黑色区域?
部分截图供参考:(
我最终希望得到圈内的那个数字)
代码:
LTTTableViewCell:
- (void)awakeFromNib {
[super awakeFromNib];
// Create a square view using the height of the 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 a new rect with some padding
// + create a circle from this 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 to show the black area
[ballBezierPath stroke];
[ballBezierPath fill];
[self setBackgroundColor:[UIColor clearColor]]; // Happens with and without this line
}