★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤微信公衆號:山青詠芝(shanqingyongzhi)
➤博客園地址:山青詠芝(https://www.cnblogs.com/strengthen/)
➤GitHub地址:https://github.com/strengthen/LeetCode
➤原文地址:http://www.javashuo.com/article/p-wegrioyk-mc.html
➤若是連接不是山青詠芝的博客園地址,則多是爬取做者的文章。
➤原文已修改更新!強烈建議點擊原文地址閱讀!支持做者!支持原創!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★html
目錄:[Swift]通天遁地Swiftios
本文將演示使用第三方類庫,快速實現位移動畫。git
首先確保已經安裝了所需的第三方類庫。雙擊查看安裝配置文件【Podfile】 github
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
根據配置文件中的相關設置,安裝第三方類庫。swift
安裝完成以後,雙擊打開項目文件【DemoApp.xcodeproj】xcode
在左側的項目導航區,打開視圖控制器的代碼文件【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, width: 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 }