我正在尝试通过 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 表视图的位置并运行代码,我可以看到部分图像
如果您对此有任何想法,请帮助