zl程序教程

您现在的位置是:首页 >  其它

当前栏目

[翻译] JTSlideShadowAnimation

翻译
2023-09-14 08:57:16 时间

JTSlideShadowAnimation

效果图:

JTSlideShadowAnimation allow you to reproduce the famous "slide to unlock effect" on iOS.

JTSlideShadowAnimation能让你重现巨好看的“锁屏滑动辉光”效果

Usage - 使用

Basic usage - 基本使用方法

Just import JTSlideShadowAnimation.h.

只要引入 JTSlideShadowAnimation.h 文件即可

#import "JTSlideShadowAnimation.h"

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIButton *animatedView;

@property (strong, nonatomic) JTSlideShadowAnimation *shadowAnimation;

@end

Assign the view you want to animate and start the animation.

给你想要的view附上值,然后执行动画

- (void)viewDidLoad

 [super viewDidLoad];

 self.shadowAnimation = [JTSlideShadowAnimation new];

 self.shadowAnimation.animatedView = self.animatedView;

- (void)viewDidAppear:(BOOL)animated

 [super viewDidAppear:animated];

 [self.shadowAnimation start];

}

Customization - 定制

You can easily customize the animation.

你可以简单定制以下的一些属性

shadowBackgroundColor shadowForegroundColor shadowWidth repeatCount duration

Example:

例子:

- (void)viewDidLoad

 [super viewDidLoad];

 self.shadowAnimation = [JTSlideShadowAnimation new];

 self.shadowAnimation.animatedView = self.animatedView;

 self.shadowAnimation.shadowBackgroundColor = [UIColor colorWithWhite:0. alpha:.3];

 self.shadowAnimation.shadowForegroundColor = [UIColor blackColor];

 self.shadowAnimation.shadowWidth = 40.;

 self.shadowAnimation.repeatCount = 3;

 self.shadowAnimation.duration = 3.;

 [self.shadowAnimation start];

}

Requirements - 需要的环境

iOS 7 or higher iOS7或者更高版本 Automatic Reference Counting (ARC) ARC

Known Issues - 已知的问题

Animation stop when the application go in background, you have to restart it manually 程序进入后台然后进入前台时,动画会被移除,需要你手动重新开启

Author - 作者

Jonathan Tribouharet (@johntribouharet)

License - 声明

JTSlideShadowAnimation is released under the MIT license. See the LICENSE file for more info. 

JTSlideShadowAnimation基于MIT协议,你可以看看协议了解更多信息。

 

附录源码:

//

// ViewController.m

// ShowAnimation

// Created by YouXianMing on 14/12/26.

// Copyright (c) 2014年 YouXianMing. All rights reserved.

#import "ViewController.h"

#import "JTSlideShadowAnimation.h"

@interface ViewController ()

@property (strong, nonatomic) UIButton *animatedView;

@property (strong, nonatomic) JTSlideShadowAnimation *shadowAnimation;

@implementation ViewController

- (void)viewDidLoad {

 [super viewDidLoad];

 // 设置背景图片

 UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];

 imageView.image = [UIImage imageNamed:@"background"];

 imageView.contentMode = UIViewContentModeScaleAspectFill;

 [self.view addSubview:imageView];

 // 设置按钮

 self.animatedView = [[UIButton alloc] initWithFrame:CGRectMake(0, 30, 320, 30)];

 self.animatedView.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Thin"

 size:20.f];

 [self.animatedView setTitle:@"YouXianMing NoZuoNoDie"

 forState:UIControlStateNormal];

 [self.animatedView setTitleColor:[UIColor whiteColor]

 forState:UIControlStateNormal];

 [self.view addSubview:self.animatedView];

 // 设置阴影

 self.shadowAnimation = [JTSlideShadowAnimation new];

 self.shadowAnimation.animatedView = self.animatedView;

 [self.shadowAnimation start];

@end

上周去逛图书馆,借了本德语原版的书。今天突然想起来了,就翻开来看。我不知道这本书是否有中文版的,不管有没有吧,我尝试翻译一下以提高自身的德语水平。每天花上一个半小时来翻译,我想应该不能翻译出来几句的。