我试图通过以下
通过tableHeaderView查看我的图像- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIView *tableHeaderView = [[UIView alloc] initWithFrame: CGRectMake(0.0, 0.0, self.view.frame.size.width, 180.0)];
tableHeaderView.backgroundColor = [UIColor clearColor];
UIView *blackBorderView = [[UIView alloc] initWithFrame: CGRectMake(0.0, 179.0, self.view.frame.size.width, 1.0)];
blackBorderView.backgroundColor = [UIColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 0.8];
[tableHeaderView addSubview: blackBorderView];
self.tableView.tableHeaderView = tableHeaderView;
self.tableView.tableHeaderView.backgroundColor = [UIColor clearColor];
_headerImageYOffset = 0;
_headerImage = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"myImage.png"]];
CGRect headerImageFrame = _headerImage.frame;
headerImageFrame.origin.y = _headerImageYOffset;
_headerImage.frame = headerImageFrame;
[self.view insertSubview: _headerImage belowSubview: self.tableView];
}
但是,根本看不到图像。我认为clearColor
可以帮助我看到图像。
如果我在xib中修改ny表视图的位置并运行代码,我可以看到部分图像
如果您对此有任何想法,请帮助
答案 0 :(得分:0)
表的背景不透明,请尝试
[self.tableView setBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0 ]];