iOS解锁界面的"滑动来解锁"闪烁动画效果
2016-06-22 17:11
525 查看
今天在github上看到个库,facebook搞的,非常简单的API就能完成你们看到的效果:每天解锁iPhone,看到底部“滑动来解锁”这个效果:
示例DEMO:
先导入#import "FBShimmeringView.h"类:
//! @abstract Set this to YES to start shimming and NO to stop. Defaults to NO.
//是否闪烁
//@property (nonatomic, assign, readwrite, getter = isShimmering) BOOL shimmering;
//!@abstract The time interval between shimmerings in seconds. Defaults to 0.4.
//两次闪烁之间的间隔
//@property (assign, nonatomic, readwrite) CFTimeInterval shimmeringPauseDuration;
//!@abstract The opacity of the content while it is shimmering. Defaults to 1.0.
//闪烁时动画的透明度 1.0就是原始亮度 0-1之间随意选择
//@property (assign, nonatomic, readwrite) CGFloat shimmeringAnimationOpacity;
//!@abstract The opacity of the content before it is shimmering. Defaults to 0.5.
//闪烁前的透明度,例如默认0.5,那么和上面那个参数对比下,就是0.5-1之间闪烁
//@property (assign, nonatomic, readwrite) CGFloat shimmeringOpacity;
//!@abstract The speed of shimmering, in points per second. Defaults to 230.
//闪烁的速度
//@property (assign, nonatomic, readwrite) CGFloat shimmeringSpeed;
//!@abstract The highlight length of shimmering. Range of [0,1], defaults to 0.33.
//闪烁过去的时候那条线的宽度 0 - 1之间的浮点数切换
//@property (assign, nonatomic, readwrite) CGFloat shimmeringHighlightLength;
//!@abstract @deprecated Same as "shimmeringHighlightLength", just for downward compatibility
//和上面类似
//@property (assign, nonatomic, readwrite, getter = shimmeringHighlightLength, setter = setShimmeringHighlightLength:) CGFloat shimmeringHighlightWidth;
//!@abstract The direction of shimmering animation. Defaults to FBShimmerDirectionRight.
//闪烁的方向,这个枚举有上下左右四个方向
//@property (assign, nonatomic, readwrite) FBShimmerDirection shimmeringDirection;
//!@abstract The duration of the fade used when shimmer begins. Defaults to 0.1.
//开始闪烁的时间间隔
//@property (assign, nonatomic, readwrite) CFTimeInterval shimmeringBeginFadeDuration;
//!@abstract The duration of the fade used when shimmer ends. Defaults to 0.3.
//结束闪烁的时间间隔
//@property (assign, nonatomic, readwrite) CFTimeInterval shimmeringEndFadeDuration;
/**
@abstract The absolute CoreAnimation media time when the shimmer will fade in.
@discussion Only valid after setting {@ref shimmering} to NO.
*/
//闪烁到shimmeringAnimationOpacity的时候fade需要多久
//@property (assign, nonatomic, readonly) CFTimeInterval shimmeringFadeTime;
各自属性的默认值是这样的,需要的请自行修改即可
[o
- (instancetype)init
{
self = [super init];
if (nil != self) {
// default configuration
_shimmeringPauseDuration = 0.4;
_shimmeringSpeed = 230.0;
_shimmeringHighlightLength = 1.0;
_shimmeringAnimationOpacity = 0.5;
_shimmeringOpacity = 1.0;
_shimmeringDirection = FBShimmerDirectionRight;
_shimmeringBeginFadeDuration = 0.1;
_shimmeringEndFadeDuration = 0.3;
}
return self;
}
就这么简单,设置自己喜欢的属性就好了,跑起来看看,效果已经给大家配好了,也可以自行尝试,肯定很酷炫
参考资料:
iOS之iPhone解锁界面的"滑动来解锁"闪烁动画效果,好奇的赶紧进来取走,别看了,说的就是你0.0
FBShimmering的gitHub地址
示例DEMO:
先导入#import "FBShimmeringView.h"类:
- (void)viewDidLoad { [super viewDidLoad]; //生成FBShimmeringView对象 FBShimmeringView *view1 = [[FBShimmeringView alloc] initWithFrame:CGRectMake(100, 20, 300, 100)]; view1.shimmering = YES; //闪烁效果 view1.shimmeringOpacity = 1; //闪烁视图透明度 view1.shimmeringDirection = FBShimmerDirectionRight;//闪烁动画方向 view1.shimmeringBeginFadeDuration = .5;//持续时间 view1.shimmeringPauseDuration = 0.6;//闪烁暂停时间 view1.shimmeringAnimationOpacity = .1;//闪烁动画时透明度 view1.shimmeringSpeed = 200;//闪烁速度 [self.view addSubview:view1]; UILabel *label = [[UILabel alloc] initWithFrame:view1.frame]; label.text = @"》滑 动 解 锁 》"; label.textAlignment = NSTextAlignmentCenter; label.font = [UIFont boldSystemFontOfSize:20]; label.textColor = [UIColor blackColor]; label.backgroundColor = [UIColor whiteColor]; view1.contentView = label; }
给大家加了所有字段的中文解释,自己测试出来的,可能会有写错误,(借鉴)
//! @abstract Set this to YES to start shimming and NO to stop. Defaults to NO.
//是否闪烁
//@property (nonatomic, assign, readwrite, getter = isShimmering) BOOL shimmering;
//!@abstract The time interval between shimmerings in seconds. Defaults to 0.4.
//两次闪烁之间的间隔
//@property (assign, nonatomic, readwrite) CFTimeInterval shimmeringPauseDuration;
//!@abstract The opacity of the content while it is shimmering. Defaults to 1.0.
//闪烁时动画的透明度 1.0就是原始亮度 0-1之间随意选择
//@property (assign, nonatomic, readwrite) CGFloat shimmeringAnimationOpacity;
//!@abstract The opacity of the content before it is shimmering. Defaults to 0.5.
//闪烁前的透明度,例如默认0.5,那么和上面那个参数对比下,就是0.5-1之间闪烁
//@property (assign, nonatomic, readwrite) CGFloat shimmeringOpacity;
//!@abstract The speed of shimmering, in points per second. Defaults to 230.
//闪烁的速度
//@property (assign, nonatomic, readwrite) CGFloat shimmeringSpeed;
//!@abstract The highlight length of shimmering. Range of [0,1], defaults to 0.33.
//闪烁过去的时候那条线的宽度 0 - 1之间的浮点数切换
//@property (assign, nonatomic, readwrite) CGFloat shimmeringHighlightLength;
//!@abstract @deprecated Same as "shimmeringHighlightLength", just for downward compatibility
//和上面类似
//@property (assign, nonatomic, readwrite, getter = shimmeringHighlightLength, setter = setShimmeringHighlightLength:) CGFloat shimmeringHighlightWidth;
//!@abstract The direction of shimmering animation. Defaults to FBShimmerDirectionRight.
//闪烁的方向,这个枚举有上下左右四个方向
//@property (assign, nonatomic, readwrite) FBShimmerDirection shimmeringDirection;
//!@abstract The duration of the fade used when shimmer begins. Defaults to 0.1.
//开始闪烁的时间间隔
//@property (assign, nonatomic, readwrite) CFTimeInterval shimmeringBeginFadeDuration;
//!@abstract The duration of the fade used when shimmer ends. Defaults to 0.3.
//结束闪烁的时间间隔
//@property (assign, nonatomic, readwrite) CFTimeInterval shimmeringEndFadeDuration;
/**
@abstract The absolute CoreAnimation media time when the shimmer will fade in.
@discussion Only valid after setting {@ref shimmering} to NO.
*/
//闪烁到shimmeringAnimationOpacity的时候fade需要多久
//@property (assign, nonatomic, readonly) CFTimeInterval shimmeringFadeTime;
各自属性的默认值是这样的,需要的请自行修改即可
[o
- (instancetype)init
{
self = [super init];
if (nil != self) {
// default configuration
_shimmeringPauseDuration = 0.4;
_shimmeringSpeed = 230.0;
_shimmeringHighlightLength = 1.0;
_shimmeringAnimationOpacity = 0.5;
_shimmeringOpacity = 1.0;
_shimmeringDirection = FBShimmerDirectionRight;
_shimmeringBeginFadeDuration = 0.1;
_shimmeringEndFadeDuration = 0.3;
}
return self;
}
就这么简单,设置自己喜欢的属性就好了,跑起来看看,效果已经给大家配好了,也可以自行尝试,肯定很酷炫
参考资料:
iOS之iPhone解锁界面的"滑动来解锁"闪烁动画效果,好奇的赶紧进来取走,别看了,说的就是你0.0
FBShimmering的gitHub地址
相关文章推荐
- 查看github pages文档的方式
- 使用BAE的基于Web.py的简单博客程序
- Gifski:一个跨平台的高质量 GIF 编码器
- 模仿动画的放大缩小容器
- jQuery 1.9.1源码分析系列(十五)动画处理之缓动动画核心Tween
- Android实现定制返回按钮动画效果的方法
- Android中ViewFlipper的使用及设置动画效果实例详解
- jQuery实现美观的多级动画效果菜单代码
- 两分钟学会如何在github托管代码
- php判断GIF图片是否为动画的方法
- jQuery实现动画效果circle实例
- HTML5游戏引擎LTweenLite实现的超帅动画效果(附demo源码下载)
- 浅析JavaScript动画
- js排序动画模拟-插入排序
- javascript+HTML5的Canvas实现Lab单车动画效果
- 基于javascript实现漂亮的页面过渡动画效果附源码下载
- js实现按钮颜色渐变动画效果
- 超赞的jQuery图片滑块动画特效代码汇总
- jQuery实现连续动画效果实例分析