Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/nxtstep/DGRunkeeperSwitch i…
Browse files Browse the repository at this point in the history
…nto nxtstep-master

# Conflicts:
#	DGRunkeeperSwitch/DGRunkeeperSwitch.swift
#	DGRunkeeperSwitchExample/ViewController.swift
  • Loading branch information
Danil Gontovnik committed Aug 10, 2016
2 parents cebdd95 + 3fc0d7e commit ffe62b0
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
xcuserdata
*.xccheckout
*.xcuserstate
*.xcuserstate
Build/
8 changes: 4 additions & 4 deletions DGRunkeeperSwitch.podspec
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Pod::Spec.new do |s|

s.name = "DGRunkeeperSwitch"
s.version = "1.1.1"
s.authors = { "Danil Gontovnik" => "gontovnik.danil@gmail.com" }
s.version = "1.1.3"
s.authors = { "Danil Gontovnik" => "danil@gontovnik.com" }
s.homepage = "https://github.com/gontovnik/DGRunkeeperSwitch"
s.summary = "DGRunkeeperSwitch is Runkeeper design switch control (two part segment control)."
s.source = { :git => "https://github.com/gontovnik/DGRunkeeperSwitch.git",
:tag => '1.1.1' }
:tag => '1.1.3' }
s.license = { :type => "MIT", :file => "LICENSE" }
s.platform = :ios, '8.0'
s.source_files = "DGRunkeeperSwitch/**/*.swift"

s.requires_arc = true

s.ios.deployment_target = '8.0'
s.ios.frameworks = ['UIKit', 'Foundation']
end
24 changes: 19 additions & 5 deletions DGRunkeeperSwitch/DGRunkeeperSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class DGRunkeeperSwitch: UIControl {
get { return titleLabels.map { $0.text! } }
}

@IBInspectable
private(set) public var selectedIndex: Int = 0

public var selectedBackgroundInset: CGFloat = 2.0 {
Expand All @@ -83,6 +82,12 @@ public class DGRunkeeperSwitch: UIControl {
didSet { (titleLabels + selectedTitleLabels).forEach { $0.font = titleFont } }
}

@IBInspectable
public var titleFontFamily: String = "HelveticaNeue"

@IBInspectable
public var titleFontSize: CGFloat = 18.0

public var animationDuration: NSTimeInterval = 0.3
public var animationSpringDamping: CGFloat = 0.75
public var animationInitialSpringVelocity: CGFloat = 0.0
Expand Down Expand Up @@ -142,23 +147,32 @@ public class DGRunkeeperSwitch: UIControl {
titleMaskView.backgroundColor = .blackColor()
selectedTitleLabelsContentView.layer.mask = titleMaskView.layer

// Setup default colors
backgroundColor = .blackColor()
// Setup defaul colors
if backgroundColor == nil {
backgroundColor = .blackColor()
}

selectedBackgroundColor = .whiteColor()
titleColor = .whiteColor()
selectedTitleColor = .blackColor()

// Gestures
tapGesture = UITapGestureRecognizer(target: self, action: "tapped:")
tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapped))
addGestureRecognizer(tapGesture)

panGesture = UIPanGestureRecognizer(target: self, action: "pan:")
panGesture = UIPanGestureRecognizer(target: self, action: #selector(pan))
panGesture.delegate = self
addGestureRecognizer(panGesture)

addObserver(self, forKeyPath: "selectedBackgroundView.frame", options: .New, context: nil)
}

override public func awakeFromNib() {
super.awakeFromNib()

self.titleFont = UIFont(name: self.titleFontFamily, size: self.titleFontSize)
}

// MARK: -
// MARK: Destructor

Expand Down
2 changes: 1 addition & 1 deletion DGRunkeeperSwitch/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.2</string>
<string>1.1.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
5 changes: 2 additions & 3 deletions DGRunkeeperSwitchExample/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8187.4" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8151.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -16,7 +16,6 @@
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
Expand Down
12 changes: 9 additions & 3 deletions DGRunkeeperSwitchExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="JqM-JB-8mi">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="JqM-JB-8mi">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
Expand Down Expand Up @@ -35,10 +35,16 @@
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EFc-Vj-jEB" customClass="DGRunkeeperSwitch" customModule="DGRunkeeperSwitchExample" customModuleProvider="target">
<rect key="frame" x="20" y="530" width="560" height="50"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.47843137254901957" green="0.79607843137254897" blue="0.42352941176470588" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="Ukk-Qo-fpC"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="titleFontFamily" value="Times New Roman"/>
<userDefinedRuntimeAttribute type="number" keyPath="titleFontSize">
<real key="value" value="17"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="switchValueDidChange:" destination="6an-zX-QAJ" eventType="valueChanged" id="PQ5-rv-cZ8"/>
</connections>
Expand Down
2 changes: 1 addition & 1 deletion DGRunkeeperSwitchExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ViewController: UIViewController {
runkeeperSwitch.selectedTitleColor = UIColor(red: 255.0/255.0, green: 196.0/255.0, blue: 92.0/255.0, alpha: 1.0)
runkeeperSwitch.titleFont = UIFont(name: "HelveticaNeue-Medium", size: 13.0)
runkeeperSwitch.frame = CGRect(x: 30.0, y: 40.0, width: 200.0, height: 30.0)
runkeeperSwitch.addTarget(self, action: Selector("switchValueDidChange:"), forControlEvents: .ValueChanged)
runkeeperSwitch.addTarget(self, action: #selector(ViewController.switchValueDidChange(_:)), forControlEvents: .ValueChanged)
navigationItem.titleView = runkeeperSwitch

let runkeeperSwitch2 = DGRunkeeperSwitch()
Expand Down

0 comments on commit ffe62b0

Please sign in to comment.