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
4 changes: 2 additions & 2 deletions CustomView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 34E95R7U23;
DEVELOPMENT_TEAM = 5HW626WUP4;
INFOPLIST_FILE = CustomView/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -329,7 +329,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 34E95R7U23;
DEVELOPMENT_TEAM = 5HW626WUP4;
INFOPLIST_FILE = CustomView/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Binary file not shown.
91 changes: 91 additions & 0 deletions CustomView.xcodeproj/xcshareddata/xcschemes/CustomView.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "92949A482295DAF3008EE240"
BuildableName = "CustomView.app"
BlueprintName = "CustomView"
ReferencedContainer = "container:CustomView.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "92949A482295DAF3008EE240"
BuildableName = "CustomView.app"
BlueprintName = "CustomView"
ReferencedContainer = "container:CustomView.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "92949A482295DAF3008EE240"
BuildableName = "CustomView.app"
BlueprintName = "CustomView"
ReferencedContainer = "container:CustomView.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "92949A482295DAF3008EE240"
BuildableName = "CustomView.app"
BlueprintName = "CustomView"
ReferencedContainer = "container:CustomView.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>92949A482295DAF3008EE240</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
158 changes: 142 additions & 16 deletions CustomView/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions CustomView/Controllers/ProgressBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ class ProgressBarViewController: UITableViewController {
@IBOutlet weak var widthSlider: UISlider!
@IBOutlet weak var progressSlider: UISlider!
@IBOutlet weak var targetSlider: UISlider!
@IBOutlet weak var targetLabel: UILabel!
@IBOutlet weak var progressLabel: UILabel!
@IBOutlet weak var colorSegmentedControl: UISegmentedControl!

override func viewDidLoad() {
super.viewDidLoad()

self.progressBarView?.lineWidth = CGFloat(self.widthSlider.value)
self.progressBarView?.progressValue = CGFloat(self.progressSlider.value)
self.progressBarView?.targetValue = CGFloat(self.targetSlider.value)

self.progressLabel.text = String(format: "%.2f", self.progressSlider.value * 100) + "%"

self.targetLabel.text = String(format: "%.2f", self.targetSlider.value * 100) + "%"
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
Expand All @@ -35,10 +42,22 @@ class ProgressBarViewController: UITableViewController {

@IBAction func progessChange(_ sender: Any) {
self.progressBarView?.progressValue = CGFloat(self.progressSlider.value)

self.progressLabel.text = String(format: "%.2f", self.progressSlider.value * 100) + "%"
}

@IBAction func targetChange(_ sender: Any) {
self.progressBarView?.targetValue = CGFloat(self.targetSlider.value)

self.targetLabel.text = String(format: "%.2f", self.targetSlider.value * 100) + "%"
}

@IBAction func changeColor(_ sender: Any) {
if colorSegmentedControl.selectedSegmentIndex == 0 {
self.progressBarView?.progressColor = #colorLiteral(red: 1, green: 0.2527923882, blue: 1, alpha: 0.4874785959)
} else {
self.progressBarView?.progressColor = #colorLiteral(red: 0, green: 0.3593619466, blue: 1, alpha: 0.4874785959)
}
}
}

64 changes: 56 additions & 8 deletions CustomView/Controllers/ProgressCircleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,83 @@ import UIKit

class ProgressCircleViewController: UITableViewController {

@IBOutlet weak var progressCircleView: ProgressCircleView?
@IBOutlet weak var progressCircleView1: 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!
@IBOutlet weak var targetLabel: UILabel!
@IBOutlet weak var progressLabel: UILabel!
@IBOutlet weak var colorSegmentedControl: UISegmentedControl!

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.progressCircleView1?.circleWidth = CGFloat(self.widthSlider.value)
self.progressCircleView1?.progressValue = CGFloat(self.progressSlider.value)
self.progressCircleView1?.targetValue = CGFloat(self.targetSlider.value)

self.progressCircleView2?.circleWidth = CGFloat(self.widthSlider.value)
self.progressCircleView2?.progressValue = CGFloat(self.progressSlider.value)
self.progressCircleView2?.targetValue = CGFloat(self.targetSlider.value)

self.progressCircleView3?.circleWidth = CGFloat(self.widthSlider.value)
self.progressCircleView3?.progressValue = CGFloat(self.progressSlider.value)
self.progressCircleView3?.targetValue = CGFloat(self.targetSlider.value)

self.progressLabel.text = String(format: "%.2f", self.progressSlider.value * 100) + "%"
self.targetLabel.text = String(format: "%.2f", self.targetSlider.value * 100) + "%"

}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)

self.progressCircleView?.setNeedsDisplay()
self.progressCircleView1?.setNeedsDisplay()
self.progressCircleView2?.setNeedsDisplay()
self.progressCircleView3?.setNeedsDisplay()
}

@IBAction func widthChange(_ sender: Any) {
self.progressCircleView?.circleWidth = CGFloat(self.widthSlider.value)
self.progressCircleView1?.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.progressCircleView1?.progressValue = CGFloat(self.progressSlider.value)

self.progressCircleView2?.progressValue = CGFloat(self.progressSlider.value)

self.progressCircleView3?.progressValue = CGFloat(self.progressSlider.value)

self.progressLabel.text = String(format: "%.2f", self.progressSlider.value * 100) + "%"
}

@IBAction func targetChange(_ sender: Any) {
self.progressCircleView?.targetValue = CGFloat(self.targetSlider.value)
self.progressCircleView1?.targetValue = CGFloat(self.targetSlider.value)

self.progressCircleView2?.targetValue = CGFloat(self.targetSlider.value)

self.progressCircleView3?.targetValue = CGFloat(self.targetSlider.value)

self.targetLabel.text = String(format: "%.2f", self.targetSlider.value * 100) + "%"
}


@IBAction func changeColor(_ sender: Any) {
if colorSegmentedControl.selectedSegmentIndex == 0 {
self.progressCircleView1?.progressColor = #colorLiteral(red: 1, green: 0.2527923882, blue: 1, alpha: 0.4874785959)
self.progressCircleView2?.progressColor = #colorLiteral(red: 1, green: 0.2527923882, blue: 1, alpha: 0.4874785959)
self.progressCircleView3?.progressColor = #colorLiteral(red: 1, green: 0.2527923882, blue: 1, alpha: 0.4874785959)
} else {
self.progressCircleView1?.progressColor = #colorLiteral(red: 0, green: 0.3593619466, blue: 1, alpha: 0.4874785959)
self.progressCircleView2?.progressColor = #colorLiteral(red: 0, green: 0.3593619466, blue: 1, alpha: 0.4874785959)
self.progressCircleView3?.progressColor = #colorLiteral(red: 0, green: 0.3593619466, blue: 1, alpha: 0.4874785959)
}
}
}

7 changes: 6 additions & 1 deletion CustomView/Views/ProgressBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ class ProgressBarView: UIView {
var lineColor:UIColor = UIColor.black
@IBInspectable
var targetColor:UIColor = UIColor.blue

@IBInspectable
var progressColor:UIColor = UIColor.yellow
var progressColor:UIColor = UIColor.yellow {
didSet {
setNeedsDisplay()
}
}


override func draw(_ rect: CGRect) {
Expand Down
6 changes: 5 additions & 1 deletion CustomView/Views/ProgressCircleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ class ProgressCircleView: UIView {
var circleColor:UIColor = UIColor.black

@IBInspectable
var progressColor:UIColor = UIColor.yellow
var progressColor:UIColor = UIColor.yellow {
didSet {
setNeedsDisplay()
}
}

@IBInspectable
var targetColor:UIColor = UIColor.green
Expand Down