MJRefresh下拉刷新上拉加載自定義

下拉刷新

下拉刷新 默認(rèn)

weak __typeof(self) weakSelf = self;
    // 設(shè)置回調(diào)(一旦進入刷新狀態(tài)就會調(diào)用這個refreshingBlock)
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [weakSelf loadNewData];
    }];
    
    // 馬上進入刷新狀態(tài)
    [self.tableView.mj_header beginRefreshing];

image.gif

下拉刷新 動畫圖片

 KWeakSelf(self)
    self.tableView.mj_header = [JRGifHeader headerWithRefreshingBlock:^{
           [weakself loadNewData];
       }];
    // 馬上進入刷新狀態(tài)
    [self.tableView.mj_header beginRefreshing];

JRGifHeader.h

#import <MJRefresh/MJRefresh.h>

NS_ASSUME_NONNULL_BEGIN

@interface JRGifHeader : MJRefreshGifHeader

@end

NS_ASSUME_NONNULL_END

JRGifHeader.m

#import "JRGifHeader.h"

@implementation JRGifHeader

#pragma mark - 重寫方法
#pragma mark 基本設(shè)置
- (void)prepare
{
    [super prepare];
    
    // 設(shè)置普通狀態(tài)的動畫圖片
    NSMutableArray *idleImages = [NSMutableArray array];
    for (NSUInteger i = 1; i<=60; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dropdown_anim__000%zd", I]];
        [idleImages addObject:image];
    }
     [self setImages:idleImages forState:MJRefreshStateIdle];
    
    // 設(shè)置即將刷新狀態(tài)的動畫圖片(一松開就會刷新的狀態(tài))
    NSMutableArray *refreshingImages = [NSMutableArray array];
    for (NSUInteger i = 1; i<=3; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dropdown_loading_0%zd", I]];
        [refreshingImages addObject:image];
    }
    [self setImages:refreshingImages forState:MJRefreshStatePulling];
    
    // 設(shè)置正在刷新狀態(tài)的動畫圖片
    [self setImages:refreshingImages forState:MJRefreshStateRefreshing];
}

@end
image.gif

下拉刷新 隱藏時間

 // 設(shè)置回調(diào)(一旦進入刷新狀態(tài)掐场,就調(diào)用target的action搓谆,也就是調(diào)用self的loadNewData方法)
    MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    // 設(shè)置自動切換透明度(在導(dǎo)航欄下面自動隱藏)
    header.automaticallyChangeAlpha = YES;
    // 隱藏時間
    header.lastUpdatedTimeLabel.hidden = YES;
    // 馬上進入刷新狀態(tài)
    [header beginRefreshing];
    // 設(shè)置header
    self.tableView.mj_header = header;
image.gif

下拉刷新 隱藏狀態(tài)和時間

// 設(shè)置回調(diào)(一旦進入刷新狀態(tài)扣典,就調(diào)用target的action,也就是調(diào)用self的loadNewData方法)
    JRGifHeader *header = [JRGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    // 隱藏時間
    header.lastUpdatedTimeLabel.hidden = YES;
    // 隱藏狀態(tài)
    header.stateLabel.hidden = YES;
    // 馬上進入刷新狀態(tài)
    [header beginRefreshing];
    // 設(shè)置header
    self.tableView.mj_header = header;
image.gif

下拉刷新 自定義文字

// 設(shè)置回調(diào)(一旦進入刷新狀態(tài),就調(diào)用target的action舰讹,也就是調(diào)用self的loadNewData方法)
    MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    
    // 設(shè)置文字
    [header setTitle:@"Pull down to refresh" forState:MJRefreshStateIdle];
    [header setTitle:@"Release to refresh" forState:MJRefreshStatePulling];
    [header setTitle:@"Loading ..." forState:MJRefreshStateRefreshing];
    
    // 設(shè)置字體
    header.stateLabel.font = [UIFont systemFontOfSize:15];
    header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:14];
    // 設(shè)置顏色
    header.stateLabel.textColor = [UIColor redColor];
    header.lastUpdatedTimeLabel.textColor = [UIColor blueColor];
    // 馬上進入刷新狀態(tài)
    [header beginRefreshing];
    // 設(shè)置刷新控件
    self.tableView.mj_header = header;
image.gif

下拉刷新 自定義刷新控件

 // 設(shè)置回調(diào)(一旦進入刷新狀態(tài),就調(diào)用target的action,也就是調(diào)用self的loadNewData方法)
    self.tableView.mj_header = [JRDIYHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    [self.tableView.mj_header beginRefreshing];

JRDIYHeader.h

#import <MJRefresh/MJRefresh.h>

NS_ASSUME_NONNULL_BEGIN

@interface JRDIYHeader : MJRefreshHeader

@end

NS_ASSUME_NONNULL_END

JRDIYHeader.m

#import "JRDIYHeader.h"

@interface JRDIYHeader()
@property (weak, nonatomic) UILabel *label;
@property (weak, nonatomic) UISwitch *s;
@property (weak, nonatomic) UIImageView *logo;
@property (weak, nonatomic) UIActivityIndicatorView *loading;
@end

@implementation JRDIYHeader
#pragma mark - 重寫方法
#pragma mark 在這里做一些初始化配置(比如添加子控件)
- (void)prepare
{
    [super prepare];
    
    // 設(shè)置控件的高度
    self.mj_h = 50;
    
    // 添加label
    UILabel *label = [[UILabel alloc] init];
    label.textColor = [UIColor colorWithRed:1.0 green:0.5 blue:0.0 alpha:1.0];
    label.font = [UIFont boldSystemFontOfSize:16];
    label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:label];
    self.label = label;
    
    // logo
    UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chengg"]];
    logo.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:logo];
    self.logo = logo;
    
    // loading
    UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium];
    [self addSubview:loading];
    self.loading = loading;
}

#pragma mark 在這里設(shè)置子控件的位置和尺寸
- (void)placeSubviews
{
    [super placeSubviews];

    self.label.frame = self.bounds;
    
    self.logo.bounds = CGRectMake(0, 0, self.bounds.size.width, 100);
    self.logo.center = CGPointMake(self.mj_w * 0.5, - self.logo.mj_h + 20);
    
    self.loading.center = CGPointMake(self.mj_w - 30, self.mj_h * 0.5);
}
#pragma mark 監(jiān)聽scrollView的contentOffset改變
- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
{
    [super scrollViewContentOffsetDidChange:change];

}

#pragma mark 監(jiān)聽scrollView的contentSize改變
- (void)scrollViewContentSizeDidChange:(NSDictionary *)change
{
    [super scrollViewContentSizeDidChange:change];
    
}

#pragma mark 監(jiān)聽scrollView的拖拽狀態(tài)改變
- (void)scrollViewPanStateDidChange:(NSDictionary *)change
{
    [super scrollViewPanStateDidChange:change];

}

#pragma mark 監(jiān)聽控件的刷新狀態(tài)
- (void)setState:(MJRefreshState)state
{
    MJRefreshCheckState;

    switch (state) {
        case MJRefreshStateIdle:
            [self.loading stopAnimating];
            self.label.text = @"趕緊下拉吖(開關(guān)是打醬油滴)";
            break;
        case MJRefreshStatePulling:
            [self.loading stopAnimating];
            self.label.text = @"趕緊放開我吧(開關(guān)是打醬油滴)";
            break;
        case MJRefreshStateRefreshing:
            self.label.text = @"加載數(shù)據(jù)中(開關(guān)是打醬油滴)";
            [self.loading startAnimating];
            break;
        default:
            break;
    }
}

#pragma mark 監(jiān)聽拖拽比例(控件被拖出來的比例)
- (void)setPullingPercent:(CGFloat)pullingPercent
{
    [super setPullingPercent:pullingPercent];
    
    // 1.0 0.5 0.0
    // 0.5 0.0 0.5
    CGFloat red = 1.0 - pullingPercent * 0.5;
    CGFloat green = 0.5 - 0.5 * pullingPercent;
    CGFloat blue = 0.5 * pullingPercent;
    self.label.textColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}
@end

image.gif

上拉加載

上拉加載 默認(rèn)

__weak __typeof(self) weakSelf = self;
    
    // 設(shè)置回調(diào)(一旦進入刷新狀態(tài)就會調(diào)用這個refreshingBlock)
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        [weakSelf loadMoreData];
    }];
image.gif

上拉加載 動畫圖片

// 設(shè)置回調(diào)(一旦進入刷新狀態(tài)以躯,就調(diào)用target的action,也就是調(diào)用self的loadMoreData方法)
    self.tableView.mj_footer = [JRGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

JRGifFooter.h

#import <MJRefresh/MJRefresh.h>

NS_ASSUME_NONNULL_BEGIN

@interface JRGifFooter : MJRefreshAutoGifFooter

@end

NS_ASSUME_NONNULL_END

JRGifFooter.m

#import "JRGifFooter.h"

@implementation JRGifFooter

#pragma mark - 重寫方法
#pragma mark 基本設(shè)置
- (void)prepare
{
    [super prepare];
    
    // 設(shè)置正在刷新狀態(tài)的動畫圖片
    NSMutableArray *refreshingImages = [NSMutableArray array];
    for (NSUInteger i = 1; i<=3; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dropdown_loading_0%zd", I]];
        [refreshingImages addObject:image];
    }
    [self setImages:refreshingImages forState:MJRefreshStateRefreshing];
}
@end
image.gif

上拉加載 隱藏刷新狀態(tài)的文字

// 設(shè)置回調(diào)(一旦進入刷新狀態(tài)啄踊,就調(diào)用target的action忧设,也就是調(diào)用self的loadMoreData方法)
    JRGifFooter *footer = [JRGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    
    // 當(dāng)上拉刷新控件出現(xiàn)50%時(出現(xiàn)一半),就會自動刷新颠通。這個值默認(rèn)是1.0(也就是上拉刷新100%出現(xiàn)時址晕,才會自動刷新)
    //    footer.triggerAutomaticallyRefreshPercent = 0.5;
    
    // 隱藏刷新狀態(tài)的文字
    footer.refreshingTitleHidden = YES;
    
    // 設(shè)置footer
    self.tableView.mj_footer = footer;
image.gif

上拉加載 全部加載完畢

 // 設(shè)置回調(diào)(一旦進入刷新狀態(tài),就調(diào)用target的action顿锰,也就是調(diào)用self的loadLastData方法)
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadLastData)];
image.gif

上拉加載 禁止自動加載

 // 設(shè)置回調(diào)(一旦進入刷新狀態(tài)谨垃,就調(diào)用target的action,也就是調(diào)用self的loadMoreData方法)
    MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    
    // 禁止自動加載
    footer.automaticallyRefresh = NO;
    
    // 設(shè)置footer
    self.tableView.mj_footer = footer;

上拉加載 自定義文字

 // 添加默認(rèn)的上拉刷新
    // 設(shè)置回調(diào)(一旦進入刷新狀態(tài)硼控,就調(diào)用target的action刘陶,也就是調(diào)用self的loadMoreData方法)
    MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    
    // 設(shè)置文字
    [footer setTitle:@"Click or drag up to refresh" forState:MJRefreshStateIdle];
    [footer setTitle:@"Loading more ..." forState:MJRefreshStateRefreshing];
    [footer setTitle:@"No more data" forState:MJRefreshStateNoMoreData];

    // 設(shè)置字體
    footer.stateLabel.font = [UIFont systemFontOfSize:17];

    // 設(shè)置顏色
    footer.stateLabel.textColor = [UIColor blueColor];
    
    // 設(shè)置footer
    self.tableView.mj_footer = footer;
image.gif

上拉加載 加載后隱藏

// 設(shè)置回調(diào)(一旦進入刷新狀態(tài),就調(diào)用target的action牢撼,也就是調(diào)用self的loadOnceData方法)
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadOnceData)];
image.gif

上拉加載 自動回彈的上拉01

// 設(shè)置回調(diào)(一旦進入刷新狀態(tài)匙隔,就調(diào)用target的action,也就是調(diào)用self的loadMoreData方法)
    self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    // 設(shè)置了底部inset
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 30, 0);
    // 忽略掉底部inset
    self.tableView.mj_footer.ignoredScrollViewContentInsetBottom = 30;
image.gif

上拉加載 自動回彈的上拉02

 // 設(shè)置回調(diào)(一旦進入刷新狀態(tài)熏版,就調(diào)用target的action纷责,也就是調(diào)用self的loadLastData方法)
    self.tableView.mj_footer = [JRBackGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadLastData)];
    self.tableView.mj_footer.automaticallyChangeAlpha = YES;

JRBackGifFooter.h

#import <MJRefresh/MJRefresh.h>

NS_ASSUME_NONNULL_BEGIN

@interface JRBackGifFooter : MJRefreshBackGifFooter

@end

NS_ASSUME_NONNULL_END

JRBackGifFooter.m

#import "JRBackGifFooter.h"

@implementation JRBackGifFooter

#pragma mark - 重寫方法
#pragma mark 基本設(shè)置
- (void)prepare
{
    [super prepare];
    
    // 設(shè)置普通狀態(tài)的動畫圖片
    NSMutableArray *idleImages = [NSMutableArray array];
    for (NSUInteger i = 1; i<=60; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dropdown_anim__000%zd", I]];
        [idleImages addObject:image];
    }
    [self setImages:idleImages forState:MJRefreshStateIdle];
    
    // 設(shè)置即將刷新狀態(tài)的動畫圖片(一松開就會刷新的狀態(tài))
    NSMutableArray *refreshingImages = [NSMutableArray array];
    for (NSUInteger i = 1; i<=3; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dropdown_loading_0%zd", I]];
        [refreshingImages addObject:image];
    }
    [self setImages:refreshingImages forState:MJRefreshStatePulling];
    
    // 設(shè)置正在刷新狀態(tài)的動畫圖片
    [self setImages:refreshingImages forState:MJRefreshStateRefreshing];
}
@end
image.gif

上拉加載 自定義刷新控件(自動刷新)

  // 設(shè)置回調(diào)(一旦進入刷新狀態(tài),就調(diào)用target的action纳决,也就是調(diào)用self的loadMoreData方法)
    JRDIYAutoFooter *footer = [JRDIYAutoFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    footer.autoTriggerTimes = 2;
    self.tableView.mj_footer = footer;

JRDIYAutoFooter.h

#import <MJRefresh/MJRefresh.h>

NS_ASSUME_NONNULL_BEGIN

@interface JRDIYAutoFooter : MJRefreshAutoFooter

@end

NS_ASSUME_NONNULL_END

JRDIYAutoFooter.m

#import "JRDIYAutoFooter.h"

@interface JRDIYAutoFooter()
@property (weak, nonatomic) UILabel *label;
@property (weak, nonatomic) UISwitch *s;
@property (weak, nonatomic) UIActivityIndicatorView *loading;
@end

@implementation JRDIYAutoFooter

#pragma mark - 重寫方法
#pragma mark 在這里做一些初始化配置(比如添加子控件)
- (void)prepare
{
    [super prepare];
    
    // 設(shè)置控件的高度
    self.mj_h = 50;
    
    // 添加label
    UILabel *label = [[UILabel alloc] init];
    label.textColor = [UIColor colorWithRed:1.0 green:0.5 blue:0.0 alpha:1.0];
    label.font = [UIFont boldSystemFontOfSize:16];
    label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:label];
    self.label = label;
    
    // 打醬油的開關(guān)
    UISwitch *s = [[UISwitch alloc] init];
    [self addSubview:s];
    self.s = s;
    
    // loading
   UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium];
    [self addSubview:loading];
    self.loading = loading;
}

#pragma mark 在這里設(shè)置子控件的位置和尺寸
- (void)placeSubviews
{
    [super placeSubviews];
    
    self.label.frame = self.bounds;
    self.s.center = CGPointMake(self.mj_w - 20, self.mj_h - 20);
    
    self.loading.center = CGPointMake(30, self.mj_h * 0.5);
}

#pragma mark 監(jiān)聽scrollView的contentOffset改變
- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
{
    [super scrollViewContentOffsetDidChange:change];
    
}

#pragma mark 監(jiān)聽scrollView的contentSize改變
- (void)scrollViewContentSizeDidChange:(NSDictionary *)change
{
    [super scrollViewContentSizeDidChange:change];
    
}

#pragma mark 監(jiān)聽scrollView的拖拽狀態(tài)改變
- (void)scrollViewPanStateDidChange:(NSDictionary *)change
{
    [super scrollViewPanStateDidChange:change];
    
}

#pragma mark 監(jiān)聽控件的刷新狀態(tài)
- (void)setState:(MJRefreshState)state
{
    MJRefreshCheckState;
    
    switch (state) {
        case MJRefreshStateIdle:
            self.label.text = @"趕緊上拉吖(開關(guān)是打醬油滴)";
            [self.loading stopAnimating];
            [self.s setOn:NO animated:YES];
            break;
        case MJRefreshStateRefreshing:
            [self.s setOn:YES animated:YES];
            self.label.text = @"加載數(shù)據(jù)中(開關(guān)是打醬油滴)";
            [self.loading startAnimating];
            break;
        case MJRefreshStateNoMoreData:
            self.label.text = @"木有數(shù)據(jù)了(開關(guān)是打醬油滴)";
            [self.s setOn:NO animated:YES];
            [self.loading stopAnimating];
            break;
        default:
            break;
    }
}


@end

image.gif

上拉加載 自定義刷新控件(自動回彈)

 // 設(shè)置回調(diào)(一旦進入刷新狀態(tài)碰逸,就調(diào)用target的action,也就是調(diào)用self的loadMoreData方法)
    self.tableView.mj_footer = [JRDIYBackFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

JRDIYBackFooter.h

#import <MJRefresh/MJRefresh.h>

NS_ASSUME_NONNULL_BEGIN

@interface JRDIYBackFooter : MJRefreshBackFooter

@end

NS_ASSUME_NONNULL_END

JRDIYBackFooter.m

#import "JRDIYBackFooter.h"

@interface JRDIYBackFooter()
@property (weak, nonatomic) UILabel *label;
@property (weak, nonatomic) UISwitch *s;
@property (weak, nonatomic) UIImageView *logo;
@property (weak, nonatomic) UIActivityIndicatorView *loading;
@end

@implementation JRDIYBackFooter

#pragma mark - 重寫方法
#pragma mark 在這里做一些初始化配置(比如添加子控件)
- (void)prepare
{
    [super prepare];
    
    // 設(shè)置控件的高度
    self.mj_h = 50;
    
    // 添加label
    UILabel *label = [[UILabel alloc] init];
    label.textColor = [UIColor colorWithRed:1.0 green:0.5 blue:0.0 alpha:1.0];
    label.font = [UIFont boldSystemFontOfSize:16];
    label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:label];
    self.label = label;
    
    // 打醬油的開關(guān)
    UISwitch *s = [[UISwitch alloc] init];
    [self addSubview:s];
    self.s = s;
    
    // logo
    UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chengg"]];
    logo.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:logo];
    self.logo = logo;
    
    // loading
    UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium];
    [self addSubview:loading];
    self.loading = loading;
}

#pragma mark 在這里設(shè)置子控件的位置和尺寸
- (void)placeSubviews
{
    [super placeSubviews];
    
    self.label.frame = self.bounds;
    
    self.logo.bounds = CGRectMake(0, 0, self.bounds.size.width, 100);
    self.logo.center = CGPointMake(self.mj_w * 0.5, self.mj_h + self.logo.mj_h * 0.5);
    
    self.loading.center = CGPointMake(self.mj_w - 30, self.mj_h * 0.5);
}

#pragma mark 監(jiān)聽scrollView的contentOffset改變
- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
{
    [super scrollViewContentOffsetDidChange:change];
    
}

#pragma mark 監(jiān)聽scrollView的contentSize改變
- (void)scrollViewContentSizeDidChange:(NSDictionary *)change
{
    [super scrollViewContentSizeDidChange:change];
    
}

#pragma mark 監(jiān)聽scrollView的拖拽狀態(tài)改變
- (void)scrollViewPanStateDidChange:(NSDictionary *)change
{
    [super scrollViewPanStateDidChange:change];
    
}

#pragma mark 監(jiān)聽控件的刷新狀態(tài)
- (void)setState:(MJRefreshState)state
{
    MJRefreshCheckState;
    
    switch (state) {
        case MJRefreshStateIdle:
            [self.loading stopAnimating];
            [self.s setOn:NO animated:YES];
            self.label.text = @"趕緊上拉吖(開關(guān)是打醬油滴)";
            break;
        case MJRefreshStatePulling:
            [self.loading stopAnimating];
            [self.s setOn:YES animated:YES];
            self.label.text = @"趕緊放開我吧(開關(guān)是打醬油滴)";
            break;
        case MJRefreshStateRefreshing:
            [self.loading startAnimating];
            [self.s setOn:YES animated:YES];
            self.label.text = @"加載數(shù)據(jù)中(開關(guān)是打醬油滴)";
            break;
        case MJRefreshStateNoMoreData:
            [self.loading stopAnimating];
            self.label.text = @"木有數(shù)據(jù)了(開關(guān)是打醬油滴)";
            [self.s setOn:NO animated:YES];
        default:
            break;
    }
}

#pragma mark 監(jiān)聽拖拽比例(控件被拖出來的比例)
- (void)setPullingPercent:(CGFloat)pullingPercent
{
    [super setPullingPercent:pullingPercent];
    
    // 1.0 0.5 0.0
    // 0.5 0.0 0.5
    CGFloat red = 1.0 - pullingPercent * 0.5;
    CGFloat green = 0.5 - 0.5 * pullingPercent;
    CGFloat blue = 0.5 * pullingPercent;
    self.label.textColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}


@end

image.gif
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末阔加,一起剝皮案震驚了整個濱河市饵史,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖胳喷,帶你破解...
    沈念sama閱讀 221,820評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件湃番,死亡現(xiàn)場離奇詭異,居然都是意外死亡吭露,警方通過查閱死者的電腦和手機癣亚,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,648評論 3 399
  • 文/潘曉璐 我一進店門吕座,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事面徽∨⒈撸” “怎么了馍资?”我有些...
    開封第一講書人閱讀 168,324評論 0 360
  • 文/不壞的土叔 我叫張陵穴店,是天一觀的道長。 經(jīng)常有香客問我迈嘹,道長削彬,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,714評論 1 297
  • 正文 為了忘掉前任秀仲,我火速辦了婚禮融痛,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘神僵。我一直安慰自己雁刷,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 68,724評論 6 397
  • 文/花漫 我一把揭開白布保礼。 她就那樣靜靜地躺著安券,像睡著了一般。 火紅的嫁衣襯著肌膚如雪氓英。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,328評論 1 310
  • 那天鹦筹,我揣著相機與錄音铝阐,去河邊找鬼。 笑死铐拐,一個胖子當(dāng)著我的面吹牛徘键,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播遍蟋,決...
    沈念sama閱讀 40,897評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼吹害,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了虚青?” 一聲冷哼從身側(cè)響起它呀,我...
    開封第一講書人閱讀 39,804評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后纵穿,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體下隧,經(jīng)...
    沈念sama閱讀 46,345評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,431評論 3 340
  • 正文 我和宋清朗相戀三年谓媒,在試婚紗的時候發(fā)現(xiàn)自己被綠了淆院。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,561評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡句惯,死狀恐怖土辩,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情抢野,我是刑警寧澤拷淘,帶...
    沈念sama閱讀 36,238評論 5 350
  • 正文 年R本政府宣布,位于F島的核電站蒙保,受9級特大地震影響辕棚,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜邓厕,卻給世界環(huán)境...
    茶點故事閱讀 41,928評論 3 334
  • 文/蒙蒙 一逝嚎、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧详恼,春花似錦补君、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,417評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至敞掘,卻和暖如春叽掘,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背玖雁。 一陣腳步聲響...
    開封第一講書人閱讀 33,528評論 1 272
  • 我被黑心中介騙來泰國打工更扁, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人赫冬。 一個月前我還...
    沈念sama閱讀 48,983評論 3 376
  • 正文 我出身青樓浓镜,卻偏偏與公主長得像,于是被迫代替她去往敵國和親劲厌。 傳聞我的和親對象是個殘疾皇子膛薛,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,573評論 2 359