有很多关于如何在 Ios 上进行视差的教程,我在 here 找到了一篇文章.
本文的主要思想是使表格 View 的标题透明,以便您可以通过插入表格 View 下方的图像看到:
- (void)viewDidLoad {
[super viewDidLoad];
// Create an empty table header view with small bottom border view
UIView *tableHeaderView = [[UIView alloc] initWithFrame: CGRectMake(0.0, 0.0, self.view.frame.size.width, 180.0)];
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];
[blackBorderView release];
_tableView.tableHeaderView = tableHeaderView;
[tableHeaderView release];
// Create the underlying imageview and offset it
_headerImageYOffset = -150.0;
_headerImage = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"header-image.png"]];
CGRect headerImageFrame = _headerImage.frame;
headerImageFrame.origin.y = _headerImageYOffset;
_headerImage.frame = headerImageFrame;
[self.view insertSubview: _headerImage belowSubview: _tableView];
}
我确实尝试过,但代码对我不起作用。我认为我们不能透明地制作 TableView 的标题,除非我们透明地制作整个表格...... 您是否尝试过以及对此有什么想法。欢迎大家提出宝贵意见
最佳答案
我曾经用过APParallaxHeader图书馆和它的工作就像一个魅力。我建议你尝试一下;)
关于ios - 适合 View 的视差不起作用,ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16523827/