您的位置:首页 > 编程语言 > Java开发

ios学习之动画中JNWSpringAnimation第三方库

2015-10-12 22:05 330 查看
最近几天看了老镇的动画的学习,有一部分是第三方库的应用,其便是JNWSpringAnimation的使用,首先是从github上下载这个包 在项目文件列表中创建new group 随后导入4个文件,因为是OC,所以要写桥接文件为
#import"JNWSpringAnimation"
随后在一个文件中加入一句话,忘了,
<img src="http://img.blog.csdn.net/20151020192935163?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
<img src="http://img.blog.csdn.net/20151020193152237?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
第一张图是瞧见文件,第二张图是在某一个文件中加入这句improt<UIKit/UIKit.h>
明天在加<img alt="大笑" src="http://static.blog.csdn.net/xheditor/xheditor_emot/default/laugh.gif" />
下面便是在ViewController 中加入这段代码
<pre name="code" class="plain">//  ViewController.swift//  shiyan28////  Created by HISE_CS on 15/10/10.//  Copyright  2015年 HISE_CS. All rights reserved.//import UIKitclass ViewController: UIViewController {override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view, typically from a nib.//设置红球 因为出来的是一个矩形,所以用圆角let redBall = UIView(frame: CGRectMake(50, 50, 100, 100))redBall.backgroundColor = UIColor.redColor()self.view.addSubview(redBall)//创建对象let scale = JNWSpringAnimation(keyPath: "transform.translation.x")//创建质量scale.mass = 2//设置阻尼值scale.damping = 6//弹性系数scale.stiffness = 100//设置初始值与结束值scale.fromValue = 0scale.toValue = 400//添加到redball对象redBall.layer.addAnimation(scale, forKey: scale.keyPath)redBall.transform = CGAffineTransformMakeTranslation(400, 0)}override func didReceiveMemoryWarning() {super.didReceiveMemoryWarning()// Dispose of any resources that can be recreated.}
JNW中整体的东西还不是非常的了解,因此以后在学习,先把这段代码敲上吧
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: