天天看点

UITableView 下拉header放大,statusBar改变颜色

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{  
  CGFloat width = self.view.frame.size.width;
    // 图片宽度
    CGFloat height = 200;
    // 图片高度
    CGFloat yOffset = scrollView.contentOffset.y;
    // 偏移的y值
    if(yOffset < 0)
    {
        CGFloat totalOffset = height + ABS(yOffset);
        CGFloat f = totalOffset / height;
        //拉伸后的图片的frame应该是同比例缩放。
        self.headerBGView.frame =  CGRectMake(- (width *f-width) / 2, yOffset, width * f, totalOffset);
    }



}




UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
    if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
       
            statusBar.backgroundColor = [UIColor clearColor];
    
    }