zoukankan      html  css  js  c++  java
  • [Swift通天遁地]八、媒体与动画-(8)使用开源类库快速实现位移动画

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
    ➤微信公众号:山青咏芝(shanqingyongzhi)
    ➤博客园地址:山青咏芝(https://www.cnblogs.com/strengthen/
    ➤GitHub地址:https://github.com/strengthen/LeetCode
    ➤原文地址:https://www.cnblogs.com/strengthen/p/10354552.html 
    ➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。
    ➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

    目录:[Swift]通天遁地Swift

    本文将演示使用第三方类库,快速实现位移动画。

    首先确保已经安装了所需的第三方类库。双击查看安装配置文件【Podfile】 

    1 platform :ios, '8.0'
    2 use_frameworks!
    3 
    4 target 'DemoApp' do
    5     source 'https://github.com/CocoaPods/Specs.git'
    6     pod 'Cheetah'
    7 end

    根据配置文件中的相关设置,安装第三方类库。

    安装完成之后,双击打开项目文件【DemoApp.xcodeproj】

    在左侧的项目导航区,打开视图控制器的代码文件【ViewController.swift】

     1 import UIKit
     2 //引入已经安装的第三方类库
     3 import Cheetah
     4 
     5 class ViewController: UIViewController {
     6     //添加一个未初始化的属性
     7     var box : UIView!
     8     override func viewDidLoad() {
     9         super.viewDidLoad()
    10         // Do any additional setup after loading the view, typically from a nib.
    11         
    12         //初始化一个普通的视图对象,
    13         //给该视图对象添加位移动画。
    14         box = UIView(frame:CGRect(x: 0, y: 100,  100, height: 100))
    15         //设置视图对象的背景颜色为橙色。
    16         box.backgroundColor = UIColor.orange
    17         //将视图对象添加到根视图
    18         self.view.addSubview(box)
    19         
    20         //调用视图对象的扩展方法,将视图对象通过动画的方式,向右移动100点的距离。
    21         box.cheetah.move(100,0).run()
    22     }
    23     
    24     override func didReceiveMemoryWarning() {
    25         super.didReceiveMemoryWarning()
    26         // Dispose of any resources that can be recreated.
    27     }
    28 }

  • 相关阅读:
    js学习---常用的内置对象(API)小结 :
    js第四天学习小结:
    学习js第三天小结
    学习js第二天小结
    tomcat+redis会话共享
    linux文件归档脚本
    服务器群秒级别文件同步(ssh+SHELL)
    elasticsearch的索引自动清理及自定义清理
    ELK安装配置
    Logstash自带正则表达式
  • 原文地址:https://www.cnblogs.com/strengthen/p/10354552.html
Copyright © 2011-2022 走看看