Skip to content

Commit 6216e52

Browse files
committed
Default to iOS system colors where supported
1 parent af6da1a commit 6216e52

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

Example/TactileSlider/Base.lproj/Main.storyboard

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
97
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
108
</dependencies>
119
<scenes>
@@ -22,7 +20,7 @@
2220
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2321
<subviews>
2422
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="23G-Tb-ylv" customClass="TactileSlider" customModule="TactileSlider">
25-
<rect key="frame" x="40" y="28" width="295" height="50"/>
23+
<rect key="frame" x="40" y="8" width="295" height="50"/>
2624
<constraints>
2725
<constraint firstAttribute="height" constant="50" id="65V-NR-045"/>
2826
</constraints>
@@ -41,7 +39,7 @@
4139
</userDefinedRuntimeAttributes>
4240
</view>
4341
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZDQ-j3-34d" customClass="TactileSlider" customModule="TactileSlider">
44-
<rect key="frame" x="40" y="94" width="295" height="50"/>
42+
<rect key="frame" x="40" y="74" width="295" height="50"/>
4543
<constraints>
4644
<constraint firstAttribute="height" constant="50" id="m7t-26-N1I"/>
4745
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="m8H-yC-WUi"/>
@@ -61,7 +59,7 @@
6159
</userDefinedRuntimeAttributes>
6260
</view>
6361
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NV5-ku-zjX" customClass="TactileSlider" customModule="TactileSlider">
64-
<rect key="frame" x="40" y="160" width="50" height="200"/>
62+
<rect key="frame" x="40" y="140" width="50" height="200"/>
6563
<constraints>
6664
<constraint firstAttribute="height" constant="200" id="4TB-1l-iv7"/>
6765
<constraint firstAttribute="width" constant="50" id="lfI-TE-EZW"/>
@@ -81,7 +79,7 @@
8179
</userDefinedRuntimeAttributes>
8280
</view>
8381
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BEf-fM-pCA" customClass="TactileSlider" customModule="TactileSlider">
84-
<rect key="frame" x="106" y="160" width="50" height="200"/>
82+
<rect key="frame" x="106" y="140" width="50" height="200"/>
8583
<constraints>
8684
<constraint firstAttribute="height" constant="200" id="58T-8W-JNq"/>
8785
<constraint firstAttribute="width" constant="50" id="opn-u5-eqk"/>
@@ -101,7 +99,6 @@
10199
</userDefinedRuntimeAttributes>
102100
</view>
103101
</subviews>
104-
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
105102
<constraints>
106103
<constraint firstItem="ZDQ-j3-34d" firstAttribute="top" secondItem="23G-Tb-ylv" secondAttribute="bottom" constant="16" id="9x1-B7-qL8"/>
107104
<constraint firstAttribute="trailingMargin" secondItem="ZDQ-j3-34d" secondAttribute="trailing" constant="24" id="aki-QV-i5v"/>

Example/TactileSlider/ViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ class ViewController: UIViewController {
1414
override func viewDidLoad() {
1515
super.viewDidLoad()
1616
// Do any additional setup after loading the view, typically from a nib.
17+
18+
if #available(iOS 13, *) {
19+
self.view.backgroundColor = UIColor.systemBackground
20+
} else {
21+
self.view.backgroundColor = UIColor.lightGray
22+
}
1723
}
1824

1925
override func didReceiveMemoryWarning() {

TactileSlider/Classes/TactileSlider.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,26 @@ import UIKit
8585
@IBInspectable open var scaleUpWhenInUse: Bool = false
8686

8787
/// The color of the track the slider slides along
88-
@IBInspectable open var trackBackground: UIColor = UIColor.darkGray {
88+
@IBInspectable open var trackBackground: UIColor = {
89+
if #available(iOS 13, *) {
90+
return .systemFill
91+
} else {
92+
return .darkGray
93+
}
94+
}() {
8995
didSet {
9096
renderer.trackBackground = trackBackground
9197
}
9298
}
9399

94100
/// The color of the value indicator part of the slider
95-
@IBInspectable open var thumbTint: UIColor = UIColor.white {
101+
@IBInspectable open var thumbTint: UIColor = {
102+
if #available(iOS 13, *) {
103+
return .label
104+
} else {
105+
return .white
106+
}
107+
}() {
96108
didSet {
97109
renderer.thumbTint = thumbTint
98110
}

0 commit comments

Comments
 (0)