diff --git a/CustomView.xcodeproj/project.pbxproj b/CustomView.xcodeproj/project.pbxproj index 73ab43a..a8a5231 100644 --- a/CustomView.xcodeproj/project.pbxproj +++ b/CustomView.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 7DAB894B229DAC7F00066A1C /* MultipleCirclesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DAB894A229DAC7F00066A1C /* MultipleCirclesViewController.swift */; }; + 7DAB894D229DAE9400066A1C /* CirclewWithLableTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DAB894C229DAE9400066A1C /* CirclewWithLableTableViewController.swift */; }; 92949A4D2295DAF3008EE240 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92949A4C2295DAF3008EE240 /* AppDelegate.swift */; }; 92949A4F2295DAF3008EE240 /* ProgressCircleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92949A4E2295DAF3008EE240 /* ProgressCircleViewController.swift */; }; 92949A522295DAF3008EE240 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 92949A502295DAF3008EE240 /* Main.storyboard */; }; @@ -18,6 +20,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 7DAB894A229DAC7F00066A1C /* MultipleCirclesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultipleCirclesViewController.swift; sourceTree = ""; }; + 7DAB894C229DAE9400066A1C /* CirclewWithLableTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CirclewWithLableTableViewController.swift; sourceTree = ""; }; 92949A492295DAF3008EE240 /* CustomView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 92949A4C2295DAF3008EE240 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 92949A4E2295DAF3008EE240 /* ProgressCircleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressCircleViewController.swift; sourceTree = ""; }; @@ -45,6 +49,8 @@ isa = PBXGroup; children = ( 92949A4E2295DAF3008EE240 /* ProgressCircleViewController.swift */, + 7DAB894C229DAE9400066A1C /* CirclewWithLableTableViewController.swift */, + 7DAB894A229DAC7F00066A1C /* MultipleCirclesViewController.swift */, 92FB2168229A55C5000AF93E /* ProgressBarViewController.swift */, ); path = Controllers; @@ -164,6 +170,8 @@ 92949A622295E067008EE240 /* ProgressBarView.swift in Sources */, 92FB2169229A55C5000AF93E /* ProgressBarViewController.swift in Sources */, 92949A602295DBF8008EE240 /* ProgressCircleView.swift in Sources */, + 7DAB894B229DAC7F00066A1C /* MultipleCirclesViewController.swift in Sources */, + 7DAB894D229DAE9400066A1C /* CirclewWithLableTableViewController.swift in Sources */, 92949A4D2295DAF3008EE240 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/CustomView.xcodeproj/project.xcworkspace/xcuserdata/iagosalomon.xcuserdatad/UserInterfaceState.xcuserstate b/CustomView.xcodeproj/project.xcworkspace/xcuserdata/iagosalomon.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..ea56833 Binary files /dev/null and b/CustomView.xcodeproj/project.xcworkspace/xcuserdata/iagosalomon.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CustomView.xcodeproj/xcuserdata/iagosalomon.xcuserdatad/xcschemes/xcschememanagement.plist b/CustomView.xcodeproj/xcuserdata/iagosalomon.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..2a99e1a --- /dev/null +++ b/CustomView.xcodeproj/xcuserdata/iagosalomon.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + CustomView.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/CustomView/Base.lproj/Main.storyboard b/CustomView/Base.lproj/Main.storyboard index 4b8cb5b..c5a39df 100644 --- a/CustomView/Base.lproj/Main.storyboard +++ b/CustomView/Base.lproj/Main.storyboard @@ -21,11 +21,13 @@ + + - + @@ -385,6 +387,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -401,7 +523,567 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CustomView/Controllers/CirclewWithLableTableViewController.swift b/CustomView/Controllers/CirclewWithLableTableViewController.swift new file mode 100644 index 0000000..e0b2611 --- /dev/null +++ b/CustomView/Controllers/CirclewWithLableTableViewController.swift @@ -0,0 +1,63 @@ +// +// CirclewWithLableTableViewController.swift +// CustomView +// +// Created by iago salomon on 28/05/19. +// Copyright © 2019 Joaquim Pessoa Filho. All rights reserved. +// + +import UIKit + +class CirclewWithLableTableViewController: UITableViewController { + + + @IBOutlet weak var progressCircleView: ProgressCircleView? + @IBOutlet weak var widthSlider: UISlider! + @IBOutlet weak var progressSlider: UISlider! + @IBOutlet weak var progressLabel: UILabel! + @IBOutlet weak var targetSlider: UISlider! + @IBOutlet weak var targetLabel: UILabel! + @IBOutlet weak var button: UIButton! + + override func viewDidLoad() { + super.viewDidLoad() + + self.progressCircleView?.circleWidth = CGFloat(self.widthSlider.value) + self.progressCircleView?.progressValue = CGFloat(self.progressSlider.value) + self.progressCircleView?.targetValue = CGFloat(self.targetSlider.value) + + self.progressLabel.text = ("\(String(format: "%.2f",(CGFloat(self.progressSlider.value)*100)))%") + self.targetLabel.text = ("\(String(format: "%.2f",(CGFloat(self.targetSlider.value)*100)))%") + } + + override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + + self.progressCircleView?.setNeedsDisplay() + } + + @IBAction func widthChange(_ sender: Any) { + self.progressCircleView?.circleWidth = CGFloat(self.widthSlider.value) + } + + @IBAction func progessChange(_ sender: Any) { + self.progressCircleView?.progressValue = CGFloat(self.progressSlider.value) + self.progressLabel.text = ("\(String(format: "%.2f",(CGFloat(self.progressSlider.value)*100)))%") + } + + @IBAction func targetChange(_ sender: Any) { + self.progressCircleView?.targetValue = CGFloat(self.targetSlider.value) + self.targetLabel.text = ("\(String(format: "%.2f",(CGFloat(self.targetSlider.value)*100)))%") + + } + + @IBAction func ChageprogressColor(_ sender: UIButton) { + self.progressCircleView?.progressColor = sender.backgroundColor ?? self.progressCircleView!.progressColor + + } + @IBAction func ChangeProgressColor(_ sender: UIButton) { + self.progressCircleView?.targetColor = sender.backgroundColor ?? self.progressCircleView!.targetColor + + } + +} diff --git a/CustomView/Controllers/MultipleCirclesViewController.swift b/CustomView/Controllers/MultipleCirclesViewController.swift new file mode 100644 index 0000000..208e1fa --- /dev/null +++ b/CustomView/Controllers/MultipleCirclesViewController.swift @@ -0,0 +1,67 @@ +// +// MultipleCirclesViewController.swift +// CustomView +// +// Created by iago salomon on 28/05/19. +// Copyright © 2019 Joaquim Pessoa Filho. All rights reserved. +// + +import UIKit + +class MultipleCirclesViewController: UITableViewController { + + @IBOutlet weak var progressCircleView: ProgressCircleView? + @IBOutlet weak var progressCircleView2: ProgressCircleView? + @IBOutlet weak var progressCircleView3: ProgressCircleView? + + @IBOutlet weak var widthSlider: UISlider! + @IBOutlet weak var progressSlider: UISlider! + @IBOutlet weak var targetSlider: UISlider! + + override func viewDidLoad() { + super.viewDidLoad() + //1 + self.progressCircleView?.circleWidth = CGFloat(self.widthSlider.value) + self.progressCircleView?.progressValue = CGFloat(self.progressSlider.value) + self.progressCircleView?.targetValue = CGFloat(self.targetSlider.value) + + //2 + self.progressCircleView2?.circleWidth = CGFloat(self.widthSlider.value) + self.progressCircleView2?.progressValue = CGFloat(self.progressSlider.value) + self.progressCircleView2?.targetValue = CGFloat(self.targetSlider.value) + + + //3 + self.progressCircleView3?.circleWidth = CGFloat(self.widthSlider.value) + self.progressCircleView3?.progressValue = CGFloat(self.progressSlider.value) + self.progressCircleView3?.targetValue = CGFloat(self.targetSlider.value) + } + + override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + + self.progressCircleView?.setNeedsDisplay() + self.progressCircleView2?.setNeedsDisplay() + self.progressCircleView3?.setNeedsDisplay() + } + + @IBAction func widthChange(_ sender: Any) { + self.progressCircleView?.circleWidth = CGFloat(self.widthSlider.value) + self.progressCircleView2?.circleWidth = CGFloat(self.widthSlider.value) + self.progressCircleView3?.circleWidth = CGFloat(self.widthSlider.value) + } + + @IBAction func progessChange(_ sender: Any) { + self.progressCircleView?.progressValue = CGFloat(self.progressSlider.value) + self.progressCircleView2?.progressValue = CGFloat(self.progressSlider.value) + self.progressCircleView3?.progressValue = CGFloat(self.progressSlider.value) + } + + @IBAction func targetChange(_ sender: Any) { + self.progressCircleView?.targetValue = CGFloat(self.targetSlider.value) + self.progressCircleView2?.targetValue = CGFloat(self.targetSlider.value) + self.progressCircleView3?.targetValue = CGFloat(self.targetSlider.value) + } +} + + diff --git a/CustomView/Controllers/ProgressBarViewController.swift b/CustomView/Controllers/ProgressBarViewController.swift index 7c56694..094f0b1 100644 --- a/CustomView/Controllers/ProgressBarViewController.swift +++ b/CustomView/Controllers/ProgressBarViewController.swift @@ -40,5 +40,15 @@ class ProgressBarViewController: UITableViewController { @IBAction func targetChange(_ sender: Any) { self.progressBarView?.targetValue = CGFloat(self.targetSlider.value) } + + @IBAction func ChageprogressColor(_ sender: UIButton) { + self.progressCircleView?.progressColor = sender.backgroundColor ?? self.progressCircleView!.progressColor + + } + @IBAction func ChangeProgressColor(_ sender: UIButton) { + self.progressCircleView?.targetColor = sender.backgroundColor ?? self.progressCircleView!.targetColor + + } + } diff --git a/CustomView/Views/ProgressCircleView.swift b/CustomView/Views/ProgressCircleView.swift index 9eb1956..a0e62b1 100644 --- a/CustomView/Views/ProgressCircleView.swift +++ b/CustomView/Views/ProgressCircleView.swift @@ -38,13 +38,25 @@ class ProgressCircleView: UIView { } @IBInspectable - var circleColor:UIColor = UIColor.black + var circleColor:UIColor = UIColor.black{ + didSet{ + setNeedsDisplay() + } + } @IBInspectable - var progressColor:UIColor = UIColor.yellow + var progressColor:UIColor = UIColor.yellow{ + didSet{ + setNeedsDisplay() + } + } @IBInspectable - var targetColor:UIColor = UIColor.green + var targetColor:UIColor = UIColor.green{ + didSet{ + setNeedsDisplay() + } + } // Method that draw the circle, progress and target override func draw(_ rect: CGRect) {