简体   繁体   English

iOS7状态栏就像本机天气应用程序一样

[英]iOS7 Status Bar like the native weather app

Does anyone know how can I reproduce a similar effect from the native iOS7 weather app? 有谁知道如何从原生iOS7天气应用程序重现类似的效果?

Basically, the status bar inherits the view's background underneath, but the content doesn't show up. 基本上,状态栏会继承下面的视图背景,但内容不会显示。 Also, a 1 pixel line is drawn after the 20 pixels height of the status bar, only if some content is underlayed. 此外,在状态栏的20个像素高度之后绘制1像素线,仅当一些内容被底层时。

在此输入图像描述

The best thing is to make it through the clipSubview of the view. 最好的方法是通过视图的clipSubview来实现它。 You put your content into the view and make constraints to left/right/bottom and height. 您将内容放入视图中并对左/右/底部和高度进行约束。 Height on scroll view you check is the cell has minus position and at that time you start to change the height of content (clip) view to get desired effect. 您检查的滚动视图的高度是单元格具有负位置,此时您开始更改内容(剪辑)视图的高度以获得所需的效果。

This is a real app you can download and take a look from www.fancyinteractive.com. 这是一个真正的应用程序,您可以从www.fancyinteractive.com下载并查看。 This functionality will be available soon as next update. 下次更新时,此功能即将推出。

- (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;
}

起始页面

滚动第一项

滚动第二个itme

You can accomplish this by setting a mask to the table view's layer. 您可以通过将掩码设置为表视图的图层来完成此操作。 You will not be able however to render the animations inside the cells, but you can do those yourself behind the table view, and track their movement with the table view's scrollview delegate methods. 但是,您无法在单元格内渲染动画,但您可以在表格视图后面自己完成这些动画,并使用表格视图的scrollview委托方法跟踪它们的移动。

Here is some informations on CALayer masks: http://evandavis.me/blog/2013/2/13/getting-creative-with-calayer-masks 以下是CALayer面具的一些信息: http//evandavis.me/blog/2013/2/13/getting-creative-with-calayer-masks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM