由于最近没什么项目,所以就试着模仿做了一些 App 的框架或者效果,今天做的是模仿 UC 浏览器个人中心的下拉效果,也有人称之为果冻效果或者是阻尼效果,本文用到了drawRect进行了底层的画线,不过还是很简单的只要把封装好的 MyHeaderView 放入工程中即可
效果图如下:
实现如下
ViewController.m:
//
// ViewController.m
// PullAnimation
//
// Created by Amydom on 16/10/29.
// Copyright © 2016年 Amydom. All rights reserved.
//
#import "ViewController.h"
#import "MyHeaderView.h"
@interface ViewController () <UITableViewDelegate, UITableViewDataSource>
@property (strong, nonatomic) MyHeaderView *headerView; // 上面蓝色的 view,可以自定义
@property (strong, nonatomic) UITableView *tableView;
@property (assign, nonatomic) CGFloat headerViewHeight; // headerView 高度
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.headerViewHeight = 180;
[self createView];
}
#pragma mark - initView
- (void)createView{
_tableView = [[UITableView alloc] init];
_tableView.frame = self.view.bounds;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.rowHeight =