Skip to content

Parallax scrolling effect on UITableView header view when a tableView is scrolled

License

Notifications You must be signed in to change notification settings

itanchao/TCParallax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCParallax

写在前面:

Parallax scrolling effect on UITableView header view when a tableView is scrolled

使用

platform :ios, ‘8.0’ 
use_frameworks!
target "TCParallaxExample" do
	pod 'TCParallax'
end

API

 ///  创建一个只有一张图片的headerView
 ///
 ///  - parameter image:     要展示的图片
 ///  - parameter forSize:   view大xiao
 ///  - parameter referView: 依赖view(headerView会依赖于这个view形变)
static func creatParallaxScrollViewWithImage(image:UIImage,forSize:CGSize,referView:UIScrollView?) -> ParallaxScrollView 

 ///  将一个view改造成ParallaxView
 ///
 ///  - parameter subView:   view
 ///  - parameter referView: 依赖view(headerView会依赖于这个view形变)
static func creatParallaxScrollViewWithSubView(subView:UIView,referView:UIScrollView) -> ParallaxScrollView 

使用

Swift

let headerView = ParallaxScrollView.creatParallaxScrollViewWithImage(UIImage(named: "imageDemo.jpg")!, forSize: CGSize(width: tableView.bounds.width, height: 300),referView: tableView) 
tableView.tableHeaderView = headerView

Object-C

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _tableView.tableHeaderView = [ParallaxScrollView creatParallaxScrollViewWithSubView:self.headerView referView:_tableView];
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.rowHeight = 45;
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}
- (EditeUserHeaderView *)headerView{
    if (!_headerView) {
        _headerView = [[EditeUserHeaderView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 167)];
        _headerView.backgroundColor = Color(@"#040406");
        _headerView.delegate = self;
         _headerView.user = self.user;
    }
    return _headerView;
}

solarized vim

About

Parallax scrolling effect on UITableView header view when a tableView is scrolled

Resources

License

Stars

Watchers

Forks

Packages

No packages published