浩晨众云网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
主要原理是根据,UITableView 的 contentOffset 的偏移量计算头部 tableHeaderView 中的 UIImageView 的高度,并实时改变
// iOS 9 之前的API - (void)willMoveToSuperview:(UIView *)newSuperview
- (void)willMoveToSuperview:(nullable UIView *)newSuperview
{
[super willMoveToSuperview:newSuperview];
_scrollView = (UIScrollView *)newSuperview;
_imgView.frame = CGRectMake(0, 0, newSuperview.bounds.size.width, self.frame.size.height);
[_scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
[_scrollView addObserver:self forKeyPath:@"contentInset" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
}
// iOS 9 之前的API - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary
{
if (object == _scrollView) {
NSLog(@"TableHeadScaleView %f", _scrollView.contentOffset.y);
if ([keyPath isEqualToString:@"contentOffset"]) {
if (_scrollView.contentOffset.y < 0) {
_imgView.frame = CGRectMake(0, _scrollView.contentOffset.y, _imgView.bounds.size.width, 90+ABS(_scrollView.contentOffset.y));
}
}else if ([keyPath isEqualToString:@"contentInset"]) {
}
}
}
创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。