【发布时间】:2014-06-12 00:38:40
【问题描述】:
我们中的许多人一定遇到过像 Tinder 和 Dripper 这样的应用程序,您可以在其中下拉包含图像的视图并放大图像。然后当您放开它时,图像缩小以返回其原始状态。
让我们以 Tinder 为例:
原始状态:和拉动时的放大状态:
在 iOS 中由
完成- (void)viewDidLoad {
[super viewDidLoad];
self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"church-welcome.png"]];
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
self.cachedImageViewSize = self.imageView.frame;
[self.tableView addSubview:self.imageView];
[self.tableView sendSubviewToBack:self.imageView];
self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 170)];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat y = -scrollView.contentOffset.y;
if (y > 0) {
self.imageView.frame = CGRectMake(0, scrollView.contentOffset.y, self.cachedImageViewSize.size.width+y, self.cachedImageViewSize.size.height+y);
self.imageView.center = CGPointMake(self.view.center.x, self.imageView.center.y);
}
}
由于我在 Objective C 和 iOS 方面的专业知识非常有限,我无法在 Android 中实现它。
这是我认为应该做的:
- 捕捉下拉手势
- 通过拉取量增加视图的高度
- 对图像进行某种缩放动画以使其适合展开的视图
有没有人知道是否有任何库可以用于此目的?
【问题讨论】: