• Shimmer辉光动画效果


    Shimmer辉光动画效果

    效果

    源码

    https://github.com/facebook/Shimmer

    https://github.com/YouXianMing/Animations

    //
    //  ShimmerController.m
    //  Animations
    //
    //  Created by YouXianMing on 15/12/18.
    //  Copyright © 2015年 YouXianMing. All rights reserved.
    //
    
    #import "ShimmerController.h"
    #import "UIView+SetRect.h"
    #import "FBShimmeringLayer.h"
    #import "FBShimmeringView.h"
    #import "StrokeCircleLayerConfigure.h"
    
    @interface ShimmerController ()
    
    @end
    
    @implementation ShimmerController
    
    - (void)setup {
    
        [super setup];
        
        self.backgroundView.backgroundColor = [UIColor blackColor];
        
        {
            FBShimmeringView *shimmeringView = [[FBShimmeringView alloc] initWithFrame:self.contentView.bounds];
            shimmeringView.shimmering                  = YES;
            shimmeringView.shimmeringBeginFadeDuration = 0.3;
            shimmeringView.shimmeringOpacity           = 0.3;
            [self.contentView addSubview:shimmeringView];
            
            UILabel *logoLabel         = [[UILabel alloc] initWithFrame:shimmeringView.bounds];
            logoLabel.text             = @"Shimmer";
            logoLabel.font             = [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:60.0];
            logoLabel.textColor        = [UIColor whiteColor];
            logoLabel.textAlignment    = NSTextAlignmentCenter;
            logoLabel.backgroundColor  = [UIColor clearColor];
            shimmeringView.contentView = logoLabel;
        }
        
        {
            FBShimmeringLayer *shimmeringLayer          = [FBShimmeringLayer layer];
            shimmeringLayer.frame                       = (CGRect){CGPointZero, CGSizeMake((130 + 1) * 2, (130 + 1) * 2)};
            shimmeringLayer.position                    = self.contentView.center;
            shimmeringLayer.shimmering                  = YES;
            shimmeringLayer.shimmeringBeginFadeDuration = 0.3;
            shimmeringLayer.shimmeringOpacity           = 0.3;
            shimmeringLayer.shimmeringPauseDuration     = 0.6f;
            [self.contentView.layer addSublayer:shimmeringLayer];
            
            CAShapeLayer *circleShape          = [CAShapeLayer layer];
            StrokeCircleLayerConfigure *config = [StrokeCircleLayerConfigure new];
            config.lineWidth                   = 1.f;
            config.startAngle                  = 0;
            config.endAngle                    = M_PI * 2;
            config.radius                      = 130.f;
            config.strokeColor                 = [UIColor redColor];
            [config configCAShapeLayer:circleShape];
            
            shimmeringLayer.contentLayer = circleShape;
        }
    }
    
    - (void)buildTitleView {
        
        [super buildTitleView];
        
        // Title label.
        UILabel *headlinelabel      = [UILabel new];
        headlinelabel.font          = Font_Avenir(20.f);
        headlinelabel.textAlignment = NSTextAlignmentCenter;
        headlinelabel.textColor     = [UIColor redColor];
        headlinelabel.text          = self.title;
        [headlinelabel sizeToFit];
        
        headlinelabel.center = self.titleView.middlePoint;
        
        FBShimmeringView *shimmeringView = [[FBShimmeringView alloc] initWithFrame:self.titleView.bounds];
        shimmeringView.shimmering                  = YES;
        shimmeringView.shimmeringBeginFadeDuration = 0.3;
        shimmeringView.shimmeringOpacity           = 0.3;
        [self.titleView addSubview:shimmeringView];
        
        shimmeringView.contentView = headlinelabel;
        
        // Line.
        UIView *line         = [[UIView alloc] initWithFrame:CGRectMake(0, 63.5, self.view.width, 0.5f)];
        line.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.25f];
        [self.titleView addSubview:line];
        [self.titleView addSubview:headlinelabel];
        
        // Back button.
        UIImage  *image      = [UIImage imageNamed:@"backIconVer2"];
        UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 64)];
        backButton.center    = CGPointMake(20, self.titleView.middleY);
        [backButton setImage:image forState:UIControlStateNormal];
        [backButton addTarget:self action:@selector(popSelf) forControlEvents:UIControlEventTouchUpInside];
        [backButton.imageView setContentMode:UIViewContentModeCenter];
        [self.titleView addSubview:backButton];
    }
    
    - (void)popSelf {
        
        [self popViewControllerAnimated:YES];
    }
    
    
    @end

    细节

  • 相关阅读:
    sql server 检测是否更新并输出更新的数据
    SQL Cross Join
    使用editplus删除 telepro的标记
    201671010104 初学Java的感想以及认知
    201671010104学习Java心得
    201671010104学习Java程序设计进度条
    从 URL 调用 WebService
    初识 Adobe AIR
    Adobe AIR 初体验:第一个Adobe AIR 的项目
    Float元素父容器在Firefox中自动撑大的方法
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/5058209.html
Copyright © 2020-2023  润新知