iOS7状态栏就像本机天气应用程序一样 [英] iOS7 Status Bar like the native weather app

查看:187
本文介绍了iOS7状态栏就像本机天气应用程序一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何从原生iOS7天气应用中重现类似效果?

Does anyone know how can I reproduce a similar effect from the native iOS7 weather app?

基本上,状态栏会继承下面的视图背景,但内容不会出现了。
此外,在状态栏的20像素高度之后绘制1像素线,仅当某些内容被保留时。

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.

推荐答案

最好的事情是通过视图的clipSubview来实现它。您将内容放入视图中并对左/右/底部和高度进行约束。您检查的滚动视图的高度是单元格具有减号位置,此时您开始更改内容(剪辑)视图的高度以获得所需的效果。

The best thing is to make it through the clipSubview of the view. 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.

这是一个真正的应用程序,您可以从www.fancyinteractive.com下载并查看。此功能将在下次更新时提供。

This is a real app you can download and take a look from 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;
}

这篇关于iOS7状态栏就像本机天气应用程序一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆