ios - 适合 View 的视差不起作用,ios

标签 ios objective-c uitableview parallax

有很多关于如何在 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/

相关文章:

ios - 在 UITextView 中选择一个词

ios - 对于长度超过其宽度的单词,将 UIButton 的标题垂直居中

ios - 安装 Xcode 8 测试版

ios - 是否可以在 iOS 上发送 SILENT LOCAL 通知

iphone - 在 iOS 中检查互联网连接的最简单方法是什么?

ios - 当我点击 UIBarButtonItem 时它会一直高亮

ios - 如何过滤 TableView 单元格以便过滤掉的单元格不会出现?

objective-c - 滚动到底部时向 UITableView 添加行

iphone - 用于操作 UITableViewController 中核心数据的开源 UI 框架

iOS Master-Detail 如何在点击添加项目按钮时加载新 View ?