###目的・これまでのプロセス
swiftでAnimaというアニメーションライブラリを実装しようとしています。
Animaのgithubのページ(https://github.com/satoshin21/Anima/blob/master/img/eyecatch.gif)では
¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
サンプルのアニメーションの動画
¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
is written as follows.
(コード)
と記述されていたので、以下の流れで実装を試みました。
→新しいViewControllerを作る。(ViewController2とする)
→ViewController2.swiftを追加
→storyboardのボタンとViewController2.swiftをつなぐ
→IBAction内にgithubにあったコードを貼りビルド
→・Use of unresolved identifier 'labels'
・Use of unresolved identifier 'animaView' というエラー
→ 以下を宣言
private var animaView: Anima {
return self.animaView
}
private var labels: [Anima] {
return self.labels
}
→ビルドは成功するがアニメーションを再生するボタンを押すとEXC_BAD_ACCESSとなりフリーズ
→原因は2個上で書いたreturn self.animaViewと表示
色々試しましたが解決できませんでした。
どなたか享受していただけると幸いです。
###発生している問題・エラーメッセージ
EXC_BAD_ACCESS(code=2,address=0x16fc3fff8)
###該当のソースコード
swift
1import UIKit 2import Anima 3import Charts 4import CoreGraphics 5 6class ViewController2: UIViewController { 7 8 override func viewDidLoad() { 9 super.viewDidLoad() 10 11 // Do any additional setup after loading the view. 12 } 13 14 override func didReceiveMemoryWarning() { 15 super.didReceiveMemoryWarning() 16 // Dispose of any resources that can be recreated. 17 } 18 19 20 public var animaView: Anima { 21 return animaView 22 } 23 24 public var labels: [Anima] { 25 26 return self.labels 27 28 } 29 30 @IBAction func ex3(_ sender: UIButton) { 31 32 let startAnimations: [AnimaType] = [.moveByY(-50), .rotateByZDegree(90)] 33 let moveAnimations: [AnimaType] = [.moveByX(50), .rotateByZDegree(90)] 34 let endAnimations: [AnimaType] = [.moveByY(-50), . 35 rotateByZDegree(90)] 36 37 func labelAnimaOption(index: Int) -> [AnimaOption] { 38 let labelAnima = labels[index].layer?.anima 39 40 return [.completion({ 41 labelAnima?.then(.opacity(1)).fire() 42 })] 43 } 44 45 46 animaView.layer?.anima 47 .then(.opacity(1.0)) 48 .then(group: startAnimations) 49 .then(group: moveAnimations, options: labelAnimaOption(index: 0)) 50 .then(group: moveAnimations, options: labelAnimaOption(index: 1)) 51 .then(group: moveAnimations, options: labelAnimaOption(index: 2)) 52 .then(group: moveAnimations, options: labelAnimaOption(index: 3)) 53 .then(group: endAnimations, options: labelAnimaOption(index: 4)) 54 .then(group: [.scaleBy(0.0), AnimaType.opacity(0.0)]) 55 56 57 } 58 59
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/05/25 06:07