Iphone UIRectFill在iOS 7中不起作用
尝试在UITableViewCell中绘制矩形Iphone UIRectFill在iOS 7中不起作用,iphone,ios,ipad,ios6,ios7,Iphone,Ios,Ipad,Ios6,Ios7,尝试在UITableViewCell中绘制矩形 //Works with iOS6 and earlier but NOT with ( iOS7 ) - (void)drawRect:(CGRect)rect { // Creating a black border [[UIColor blackColor] setFill]; UIRectFill(CGRectMake(10, 5, 40, 43)); // Filling with rig color
//Works with iOS6 and earlier but NOT with ( iOS7 )
- (void)drawRect:(CGRect)rect {
// Creating a black border
[[UIColor blackColor] setFill];
UIRectFill(CGRectMake(10, 5, 40, 43));
// Filling with rig color
[[UIColor colorWithRed:r green:g blue:b alpha:a] setFill];
UIRectFill(CGRectMake(11, 6, 38, 41));
}
有人知道为什么这在iOS 7中不起作用,但在iOS 6中起作用吗?我在iOS 7中也遇到了同样的问题-您在
-drawRect方法中绘制的任何内容都会被单元格的子视图遮住。相反,将一个新视图子类的实例作为子视图添加到单元格contentView
中,并在那里进行绘图
见和。如果您不想装箱一个自定义子类,您可以使用它。我已经通过向contentview添加一个子视图修复了它
- (id)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString *)reuseIdentifier{
if(!self)
return self;
self.colorView = [[UIView alloc] initWithFrame:CGRectMake(10, 5, 40, 43)];
self.colorView.layer.borderColor = [[UIColor blackColor] CGColor];
self.colorView.layer.borderWidth = 1.0;
[self.contentView addSubview:self.colorView];
}
- (void)setActivityColor:(UIColor*)color
{
[self.colorView setBackgroundColor:color];
}
呃…更多关于它为什么不工作的信息会很有帮助。这就是为什么,我正在试图弄清楚为什么他妈的不使用iOS7。你能和你的任何UItableViewCell类一起检查这个方法吗?谢谢MrMage给我的提示。