我想通过使用UITableView创建一个网格视图(我的老问题已经指出我在这个方向),目前正在设置个别项目的意见。创建了一个显示每行3个项目的自定义UITableViewCell后,我决定将这些项目拖放到名为ItemView的UIView的子类中。UIView背景颜色
然后将此ItemView作为子视图添加到自定义UITableViewCell中以显示网格。无论如何,我已经设法创建视图,并可以让它显示一个UILabel的罚款,但我有麻烦的改变ItemView是透明的,除了它的UIViews(标签,按钮,图像等)。这里是我的UIView代码:
#import <UIKit/UIKit.h>
@interface ItemView : UIView {
}
@end
#import "ItemView.h"
@implementation ItemView
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
}
return self;
}
- (void)drawRect:(CGRect)rect {
[self setBackgroundColor:[UIColor lightGrayColor]];
}
- (void)dealloc {
[super dealloc];
}
@end
我应该在哪里设置背景颜色以使其正常工作?
干杯
嗨杰克, 你可以请张贴在这里的解决方案? – Piyush 2011-03-16 12:04:26