質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

解決済

1回答

2101閲覧

アプリ開発初心者の者です。スプラッシュ画面(?)についてです。

aisle-_-

総合スコア11

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2017/05/20 12:01

###質問内容
アプリ開発初心者の者です。ランしようとすると下のようなエラーが出てしまいます。どうやって直せば良いのでしょうか?このサイトで質問するのは初で、とてもわかりにくい質問だと思うのですがご教授いただければ幸いです。

###発生している問題・エラーメッセージ

1つ目:transformAnimation.delegate = self()//Cannot assign value of type "AppDelegate" to type "CAAnimationDelegate" 2つ目:options: UIViewAnimationOptions.transitionNone,//"transitionNone" is unavailable : use [] to construct an empty options set

###該当のソースコード

import

1 2@UIApplicationMain 3class AppDelegate: UIResponder, UIApplicationDelegate { 4 5 var window: UIWindow? 6 7 8 private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 9 10 // ▼ 1. windowの背景色にLaunchScreen.xibのviewの背景色と同じ色を設定 11 self.window = UIWindow(frame: UIScreen.main.bounds) 12 self.window!.backgroundColor = UIColor(red: 241/255, green: 196/255, blue: 15/255, alpha: 1) 13 self.window!.makeKeyAndVisible() 14 15 // ▼ 2. rootViewControllerをStoryBoardから設定 (今回はUINavigationControllerとしているが、他のViewControllerでも可) 16 let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 17 let navigationController = mainStoryboard.instantiateViewController(withIdentifier: "navigationController") 18 self.window!.rootViewController = navigationController 19 20 // ▼ 3. rootViewController.viewをロゴ画像の形にマスクし、LaunchScreen.xibのロゴ画像と同サイズ・同位置に配置 21 navigationController.view.layer.mask = CALayer() 22 navigationController.view.layer.mask?.contents = UIImage(named: "logo.png")!.cgImage 23 navigationController.view.layer.mask?.bounds = CGRect(x: 0, y: 0, width: 60, height: 60) 24 navigationController.view.layer.mask?.anchorPoint = CGPoint(x: 0.5, y: 0.5) 25 navigationController.view.layer.mask?.position = CGPoint(x: navigationController.view.frame.width / 2, y: navigationController.view.frame.height / 2) 26 27 // ▼ 4. rootViewController.viewの最前面に白いviewを配置 28 let maskBgView = UIView(frame: navigationController.view.frame) 29 maskBgView.backgroundColor = UIColor.white 30 navigationController.view.addSubview(maskBgView) 31 navigationController.view.bringSubview(toFront: maskBgView) 32 33 let transformAnimation = CAKeyframeAnimation(keyPath: "bounds") 34 transformAnimation.delegate = self//エラー 35 transformAnimation.duration = 1 36 transformAnimation.beginTime = CACurrentMediaTime() + 1 // 開始タイミングを1秒遅らせる 37 let initalBounds = NSValue(cgRect: (navigationController.view.layer.mask?.bounds)!) 38 let secondBounds = NSValue(cgRect: CGRect(x: 0, y: 0, width: 50, height: 50)) 39 let finalBounds = NSValue(cgRect: CGRect(x: 0, y: 0, width: 2000, height: 2000)) 40 transformAnimation.values = [initalBounds, secondBounds, finalBounds] 41 transformAnimation.keyTimes = [0, 0.5, 1] 42 transformAnimation.timingFunctions = [CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut), CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)] 43 transformAnimation.isRemovedOnCompletion = false 44 transformAnimation.fillMode = kCAFillModeForwards 45 navigationController.view.layer.mask?.add(transformAnimation, forKey: "maskAnimation") 46 47 // ▼ 6. rootViewController.viewの最前面に配置した白いviewを透化するアニメーション (完了後に親viewから削除) 48 UIView.animate(withDuration: 0.1, 49 delay: 1.35, 50 options: UIViewAnimationOptions.curveEaseIn, 51 animations: { 52 maskBgView.alpha = 0.0 53 }, 54 completion: { finished in 55 maskBgView.removeFromSuperview() 56 }) 57 58 // ▼ 7. rootViewController.viewを少し拡大して元に戻すアニメーション 59 UIView.animate(withDuration: 0.25, 60 delay: 1.3, 61 options: UIViewAnimationOptions.transitionNone,//エラー 62 animations: { 63 self.window!.rootViewController!.view.transform = CGAffineTransform(scaleX: 1.05, y: 1.05) 64 }, 65 completion: { finished in 66 UIView.animate(withDuration: 0.3, 67 delay: 0.0, 68 options: UIViewAnimationOptions.curveEaseInOut, 69 animations: { 70 self.window!.rootViewController!.view.transform = CGAffineTransform.identity 71 }, 72 completion: nil 73 ) 74 }) 75 76 return true 77 } 78 79 // ▼ 8. 「5.」のアニメーション完了時のdelegateメソッドを実装し、マスクを削除する 80 func animationDidStop(anim: CAAnimation!, finished flag: Bool) { 81 // remove mask when animation completes 82 self.window!.rootViewController!.view.layer.mask = nil 83 } 84 85 86 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 87 // Override point for customization after application launch. 88 return true 89 } 90 91 func applicationWillResignActive(_ application: UIApplication) { 92 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 93 // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 94 } 95 96 func applicationDidEnterBackground(_ application: UIApplication) { 97 // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 98 // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 99 } 100 101 func applicationWillEnterForeground(_ application: UIApplication) { 102 // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 103 } 104 105 func applicationDidBecomeActive(_ application: UIApplication) { 106 // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 107 } 108 109 func applicationWillTerminate(_ application: UIApplication) { 110 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 111 } 112 113 114}

###補足情報
これらのコードはこちらのサイトを参考にしました。
http://qiita.com/okmr-d/items/07731aa1ede2998d823d

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

let transformAnimation = CAKeyframeAnimation(keyPath: "bounds") transformAnimation.delegate = self//エラー

Don't assign value of type "AppDelegate" to type "CAAnimationDelegate".

options: UIViewAnimationOptions.transitionNone,//エラー

Use [] to construct an empty options set.

投稿2017/05/20 12:18

harashow1701

総合スコア854

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

aisle-_-

2017/05/20 12:27

ありがとうございます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問