【发布时间】:2014-07-28 21:47:11
【问题描述】:
我一直在尝试像在 iOS 日历应用中那样实现彩色圆点。
我想要在 textLabel 前面有圆圈的单元格,如上图所示。
我还希望在 detailTextLabel 前面有相应的圆圈,如上图所示。
我尝试使用框架内的图像来执行此操作,但它总是太大。另外,日历应用中的圆圈似乎不在单元格的 imageView 中。
我还尝试使用从另一个问题中找到的一些代码画一个圆圈。这段代码对我不起作用。这是我的 XYZCircleView.m 文件中的代码:
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef context= UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetAlpha(context, 0.5);
CGContextFillEllipseInRect(context, CGRectMake(0,0,self.frame.size.width,self.frame.size.height));
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
//CGContextStrokeEllipseInRect(context, CGRectMake(0,0,self.frame.size.width,self.frame.size.height));
CGContextStrokeEllipseInRect(context, CGRectMake(1, 1, self.frame.size.width - 2, self.frame.size.height - 2));
}
在我的cellForRow...:
CGRect positionFrame = CGRectMake(10,10,10,10);
XYZCircleView *circleView = [[XYZCircleView alloc] initWithFrame:positionFrame];
[cell.contentView addSubview:circleView];
如何做到这一点?
谢谢
【问题讨论】:
标签: ios objective-c uitableview geometry cgrect