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

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

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

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

Q&A

0回答

369閲覧

swift progressViewのアニメーション

Yuichan1210

総合スコア0

Swift

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

0グッド

0クリップ

投稿2021/06/22 07:55

TabBarController.swift

1import UIKit 2class TabBarController:UITabBarController{ 3 4 override func viewDidLoad() { 5 super.viewDidLoad() 6 mainSetUp() 7 8 UITabBar.appearance().tintColor = .green 9 } 10 11 func mainSetUp() { 12 var viewControllers = [UIViewController]() 13 14 let firstViewController = ViewController() 15 let thirdViewController = ViewController2() 16 17 let firstNavigationController = UINavigationController(rootViewController: firstViewController) 18 let thirdNavigationController = UINavigationController(rootViewController: thirdViewController) 19 20 firstNavigationController.tabBarItem = UITabBarItem(tabBarSystemItem: .bookmarks, tag: 1) 21 22 thirdNavigationController.tabBarItem = UITabBarItem(tabBarSystemItem: .contacts, tag: 1) 23 24 25 26 viewControllers.append(thirdNavigationController) 27 viewControllers.append(firstNavigationController) 28 29 30 self.setViewControllers(viewControllers, animated: false) 31 } 32} 33

ViewCOntroller.swift

1import UIKit 2 3class ViewController:UIViewController{ 4 5 var progressView:UIProgressView! 6 var progressArray:[UIProgressView] = [] 7 8 override func viewWillAppear(_ animated: Bool) { 9 super.viewWillAppear(animated) 10 11 progressBarView() 12 for i in 0 ..< progressArray.count{ 13 progressArray[i].setProgress(0.2, animated: true) 14 } 15 16 17 } 18 19 override func viewDidLoad() { 20 21 super.viewDidLoad() 22 23 self.view.backgroundColor = #colorLiteral(red: 0.8930925727, green: 0.893242538, blue: 0.8930727839, alpha: 1) 24 25 self.navigationItem.title = "タイトル" 26 self.navigationController?.navigationBar.barTintColor = .blue 27 self.navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white, .font: UIFont.systemFont(ofSize: self.view.bounds.width / 22, weight: .bold)] 28 29 } 30 31 func progressBarView(){ 32 33 let minprogress = self.view.bounds.width / 12 34 let interval = (self.view.bounds.height / 17 * 8) - (self.view.bounds.height / 18 * 8) 35 let progressInterval = (self.view.bounds.height / 17 * 8 + minprogress + interval) - (self.view.bounds.height / 17 * 8) - 4 36 37 //プログレスのラベル 38 for i in 0 ... 6{ 39 progressView = UIProgressView(frame: CGRect(x: 0, y: 0, width: self.view.bounds.height / 3 + self.view.bounds.width / 10, height: self.view.bounds.width / 10)) 40 progressView.center = CGPoint(x: self.view.bounds.width / 2, y: self.view.bounds.height / 17 * 8 + progressInterval * CGFloat(i) + 10) 41 42 progressView.transform = CGAffineTransform(scaleX: 1.0, y: 5.0) 43 progressView.trackTintColor = .lightGray 44 progressView.progressViewStyle = .default 45 progressView.progressTintColor = .blue 46 self.view.addSubview(progressView) 47 progressArray.append(progressView) 48 49 } 50 51 52 } 53 54} 55

ViewCOntroller2.swift

1import UIKit 2class ViewController2:UIViewController{ 3 4 override func viewDidLoad() { 5 super.viewDidLoad() 6 self.view.backgroundColor = .white 7 } 8 9} 10

なぜprogressViewのアニメーションが最初灰色のviewもアニメーションされてしまうのでしょうか?そして、青色のゲージのアニメーションの仕方が不自然な気がするのですが、これを直すことはできますでしょうか?

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問