有谁知道如何从 native iOS7 天气应用程序中重现类似的效果?
基本上,状态栏继承了下面 View 的背景,但内容不显示。 此外,仅当某些内容被覆盖时,才会在状态栏的 20 像素高度之后绘制一条 1 像素的线。
最佳答案
最好的办法是通过view的clipSubview来实现。您将内容放入 View 中,并对左/右/底部和高度进行约束。您检查的 ScrollView 上的高度是单元格的位置为负,此时您开始更改内容(剪辑) View 的高度以获得所需的效果。
这是一个真正的应用程序,您可以从 www.fancyinteractive.com 下载并查看。此功能将在下次更新后尽快提供。
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSArray *visibleCells = [convertorsTableView visibleCells];
if (visibleCells.count) {
for (CVConverterTableViewCell *cell in visibleCells) {
CGFloat positionYInView = [convertorsTableView convertRect:cell.frame toView:self.view].origin.y;
[self clipLayoutConstraint:cell.clipHeightLayoutConstraint withPosition:positionYInView defaultHeight:cell.frameHeight];
[cell.converterLabel layoutIfNeeded];
[cell.iconImageView layoutIfNeeded];
}
}
[self checkStatusBarSeperator:scrollView.contentOffset.y];
}
- (void)clipLayoutConstraint:(NSLayoutConstraint *)constraint withPosition:(CGFloat)position defaultHeight:(CGFloat)defaultHeight {
if (position < 0) {
constraint.constant = (defaultHeight - -position - 20 > 10) ? defaultHeight - -position - 20 : 10;
} else
constraint.constant = defaultHeight;
}
关于iphone - iOS7 状态栏像原生天气应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19031483/