Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CustomView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -18,6 +20,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
7DAB894A229DAC7F00066A1C /* MultipleCirclesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultipleCirclesViewController.swift; sourceTree = "<group>"; };
7DAB894C229DAE9400066A1C /* CirclewWithLableTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CirclewWithLableTableViewController.swift; sourceTree = "<group>"; };
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 = "<group>"; };
92949A4E2295DAF3008EE240 /* ProgressCircleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressCircleViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -45,6 +49,8 @@
isa = PBXGroup;
children = (
92949A4E2295DAF3008EE240 /* ProgressCircleViewController.swift */,
7DAB894C229DAE9400066A1C /* CirclewWithLableTableViewController.swift */,
7DAB894A229DAC7F00066A1C /* MultipleCirclesViewController.swift */,
92FB2168229A55C5000AF93E /* ProgressBarViewController.swift */,
);
path = Controllers;
Expand Down Expand Up @@ -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;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>CustomView.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
686 changes: 684 additions & 2 deletions CustomView/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions CustomView/Controllers/CirclewWithLableTableViewController.swift
Original file line number Diff line number Diff line change
@@ -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

}

}
67 changes: 67 additions & 0 deletions CustomView/Controllers/MultipleCirclesViewController.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}


10 changes: 10 additions & 0 deletions CustomView/Controllers/ProgressBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

}

18 changes: 15 additions & 3 deletions CustomView/Views/ProgressCircleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down