【发布时间】:2010-02-16 22:38:16
【问题描述】:
我正在尝试使用 UITableView 创建一个网格视图(我的旧问题已将我指向这个方向)并且目前正在为各个项目设置视图。在创建了一个每行显示 3 个项目的自定义 UITableViewCell 之后,我决定将这些项目拉入 UIView 的一个子类中,称为 ItemView。
然后这个 ItemView 将作为子视图添加到自定义 UITableViewCell 以显示网格。无论如何,我已经设法创建了视图,并且可以让它很好地显示 UILabel,但是我在将 ItemView 更改为透明时遇到了麻烦,除了其中的 UIView(标签、按钮、图像等)之外。这是我的 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
我应该在哪里设置背景颜色才能正常工作?
干杯
【问题讨论】:
-
嗨,杰克,你能在这里发布解决方案吗?