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
Binary file added .DS_Store
Binary file not shown.
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>
92 changes: 89 additions & 3 deletions CustomView/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,89 @@
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Y0j-bi-2ZE" customClass="ProgressCircleView" customModule="CustomView" customModuleProvider="target">
<rect key="frame" x="0.0" y="8" width="414" height="192"/>
<subviews>
<view opaque="NO" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="E8N-RJ-uZx" customClass="ProgressCircleView" customModule="CustomView" customModuleProvider="target">
<rect key="frame" x="41" y="19" width="332" height="154"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view opaque="NO" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KCU-fY-lDx" customClass="ProgressCircleView" customModule="CustomView" customModuleProvider="target">
<rect key="frame" x="41" y="20" width="250" height="115"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="25%" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ezJ-qP-g85">
<rect key="frame" x="98" y="57" width="55" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="50%" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yr6-2z-Aqv">
<rect key="frame" x="106" y="39" width="39" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="progressColor">
<color key="value" red="1" green="0.2527923882" blue="1" alpha="0.48747859589999998" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="progressValue">
<real key="value" value="0.25"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="targetValue">
<real key="value" value="0.75"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="circleWidth">
<real key="value" value="10"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="circleColor">
<color key="value" red="0.92143100499999997" green="0.92145264149999995" blue="0.92144101860000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="targetColor">
<color key="value" red="0.66422420739999999" green="0.66424006219999998" blue="0.66423153879999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="progressColor">
<color key="value" red="1" green="0.2527923882" blue="1" alpha="0.48747859589999998" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="progressValue">
<real key="value" value="0.25"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="targetValue">
<real key="value" value="0.75"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="circleWidth">
<real key="value" value="10"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="circleColor">
<color key="value" red="0.92143100499999997" green="0.92145264149999995" blue="0.92144101860000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="targetColor">
<color key="value" red="0.66422420739999999" green="0.66424006219999998" blue="0.66423153879999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="Y0j-bi-2ZE" secondAttribute="bottom" id="16n-4G-EzM"/>
<constraint firstAttribute="leading" secondItem="Y0j-bi-2ZE" secondAttribute="leading" id="65z-tv-uIB"/>
<constraint firstAttribute="leading" secondItem="Y0j-bi-2ZE" secondAttribute="leading" id="EBZ-C6-RXR"/>
<constraint firstAttribute="trailing" secondItem="Y0j-bi-2ZE" secondAttribute="trailing" id="GXL-Wf-xRa"/>
<constraint firstAttribute="top" secondItem="Y0j-bi-2ZE" secondAttribute="top" id="NtW-mL-5MN"/>
<constraint firstAttribute="bottom" secondItem="Y0j-bi-2ZE" secondAttribute="bottom" id="RIW-Lv-ZfO"/>
<constraint firstAttribute="top" secondItem="Y0j-bi-2ZE" secondAttribute="top" id="aGc-Sd-vuR"/>
<constraint firstAttribute="trailing" secondItem="Y0j-bi-2ZE" secondAttribute="trailing" id="bXz-dW-VS4"/>
<constraint firstAttribute="top" secondItem="Y0j-bi-2ZE" secondAttribute="top" id="d2w-FG-cp1"/>
<constraint firstAttribute="bottom" secondItem="Y0j-bi-2ZE" secondAttribute="bottom" id="e4J-L2-nfw"/>
<constraint firstAttribute="trailing" secondItem="Y0j-bi-2ZE" secondAttribute="trailing" id="ibT-XO-K5Q"/>
<constraint firstAttribute="leading" secondItem="Y0j-bi-2ZE" secondAttribute="leading" id="jFm-7Y-shI"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="progressColor">
<color key="value" red="1" green="0.2527923882" blue="1" alpha="0.48747859589041098" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -67,7 +149,7 @@
<real key="value" value="0.75"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="circleWidth">
<real key="value" value="30"/>
<real key="value" value="10"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="circleColor">
<color key="value" red="0.92143100499999997" green="0.92145264149999995" blue="0.92144101860000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -93,7 +175,7 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="25" minValue="0.0" maxValue="75" translatesAutoresizingMaskIntoConstraints="NO" id="Q8n-NL-f4d">
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="12" minValue="0.0" maxValue="75" translatesAutoresizingMaskIntoConstraints="NO" id="Q8n-NL-f4d">
<rect key="frame" x="154" y="7" width="242" height="31"/>
<connections>
<action selector="widthChange:" destination="5iR-vg-JBg" eventType="valueChanged" id="xVs-NF-C4Z"/>
Expand Down Expand Up @@ -206,14 +288,18 @@
<tabBarItem key="tabBarItem" title="Circle" image="cicle" selectedImage="cicleSelected" id="gtV-i6-qP3"/>
<connections>
<outlet property="progressCircleView" destination="Y0j-bi-2ZE" id="RfR-EA-jIc"/>
<outlet property="progressCircleView2" destination="E8N-RJ-uZx" id="lsc-j1-Cn2"/>
<outlet property="progressCircleView3" destination="KCU-fY-lDx" id="Rnx-eL-O5E"/>
<outlet property="progressLabel" destination="ezJ-qP-g85" id="8Da-1D-7HG"/>
<outlet property="progressSlider" destination="LnG-Y8-C5N" id="F4D-Sf-vHY"/>
<outlet property="targetLabel" destination="Yr6-2z-Aqv" id="i5D-ap-uw1"/>
<outlet property="targetSlider" destination="g78-nB-pd6" id="B2x-1b-VAU"/>
<outlet property="widthSlider" destination="Q8n-NL-f4d" id="DmN-qb-ZFR"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="f7H-Sn-JKP" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="848" y="143"/>
<point key="canvasLocation" x="847.82608695652175" y="142.63392857142856"/>
</scene>
<!--Bar-->
<scene sceneID="5Hn-u6-Q9Z">
Expand Down
20 changes: 20 additions & 0 deletions CustomView/Controllers/ProgressCircleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import UIKit
class ProgressCircleViewController: UITableViewController {

@IBOutlet weak var progressCircleView: ProgressCircleView?
@IBOutlet weak var progressCircleView2: ProgressCircleView!
@IBOutlet weak var progressCircleView3: ProgressCircleView!
@IBOutlet weak var targetLabel: UILabel!
@IBOutlet weak var progressLabel: UILabel!
@IBOutlet weak var widthSlider: UISlider!
@IBOutlet weak var progressSlider: UISlider!
@IBOutlet weak var targetSlider: UISlider!
Expand All @@ -21,6 +25,14 @@ class ProgressCircleViewController: UITableViewController {
self.progressCircleView?.circleWidth = CGFloat(self.widthSlider.value)
self.progressCircleView?.progressValue = CGFloat(self.progressSlider.value)
self.progressCircleView?.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)
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
Expand All @@ -31,14 +43,22 @@ class ProgressCircleViewController: UITableViewController {

@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)
self.progressLabel.text = String(format: "%.0f%%", self.progressSlider.value*100)
}

@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)
self.targetLabel.text = String(format: "%.0f%%", self.targetSlider.value*100)
}
}

3 changes: 3 additions & 0 deletions CustomView/Views/ProgressBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import UIKit

@IBDesignable
class ProgressBarView: UIView {

// Line values
@IBInspectable
var lineWidth:CGFloat = 10.0 {
didSet{
Expand All @@ -31,6 +33,7 @@ class ProgressBarView: UIView {
}
}

// Colors
@IBInspectable
var lineColor:UIColor = UIColor.black
@IBInspectable
Expand Down
13 changes: 8 additions & 5 deletions CustomView/Views/ProgressCircleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,32 @@ import UIKit
@IBDesignable
class ProgressCircleView: UIView {

// Line Values

@IBInspectable
// The value of current progress between 0.0 and 1.0
var progressValue:CGFloat = 0.0 {
var circleWidth:CGFloat = 10.0 {
didSet{
setNeedsDisplay()
}
}

@IBInspectable
// TargetValue is a value between 0.0 and 1.0 that represent the value to be archieved
var targetValue:CGFloat = 0.75 {
// The value of current progress between 0.0 and 1.0
var progressValue:CGFloat = 0.0 {
didSet{
setNeedsDisplay()
}
}

@IBInspectable
var circleWidth:CGFloat = 10.0 {
// TargetValue is a value between 0.0 and 1.0 that represent the value to be archieved
var targetValue:CGFloat = 0.75 {
didSet{
setNeedsDisplay()
}
}

// Colors
@IBInspectable
var circleColor:UIColor = UIColor.black

Expand Down