Compare commits

..

No commits in common. "master" and "v5.0.2" have entirely different histories.

23 changed files with 124 additions and 333 deletions

View File

@ -1,4 +1,4 @@
language: objective-c language: objective-c
osx_image: xcode9.3 osx_image: xcode8.3
script: xcodebuild clean && xcodebuild build -project TGPControls.xcodeproj -scheme TGPControls CODE_SIGNING_REQUIRED=NO script: xcodebuild clean && xcodebuild build -project TGPControls.xcodeproj -scheme TGPControls CODE_SIGNING_REQUIRED=NO

View File

@ -1,12 +1,11 @@
# TGP Controls
![Demo Project](TGPControlDemo.gif)
[![Build Status](https://travis-ci.org/SwiftArchitect/TGPControls.svg?branch=master)](https://travis-ci.org/SwiftArchitect/TGPControls) [![Build Status](https://travis-ci.org/SwiftArchitect/TGPControls.svg?branch=master)](https://travis-ci.org/SwiftArchitect/TGPControls)
[![CocoaPods](http://img.shields.io/cocoapods/v/TGPControls.svg)](https://cocoapods.org/pods/TGPControls) [![CocoaPods](http://img.shields.io/cocoapods/v/TGPControls.svg)](https://cocoapods.org/pods/TGPControls)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage)
![MIT License](https://img.shields.io/cocoapods/l/TGPControls.svg) ![MIT License](https://img.shields.io/cocoapods/l/TGPControls.svg)
![Demo Project](TGPControlDemo.gif)
# Slider with _ticks_ & animated Label (Swift) # Slider with _ticks_ & animated Label (Swift)
TGPControls are drop-in replacement of `UISlider` & `UILabel`, with visual preview in **Interface Builder**, single liner instrumentation, smooth animations, simple API, powerful customization. TGPControls are drop-in replacement of `UISlider` & `UILabel`, with visual preview in **Interface Builder**, single liner instrumentation, smooth animations, simple API, powerful customization.
@ -23,11 +22,10 @@ Ideal to select individual steps, star rating, integers, rainbow colors, slices
Ideal to represent steps. *The discrete slider and the camel labels can work in unison.* Ideal to represent steps. *The discrete slider and the camel labels can work in unison.*
## Compatibility ## Compatibility
1. Written in **Swift 4**, can be integrated with **Swift** or **Obj-C** 1. Written in **Swift 3**, can be integrated with **Swift** or **Obj-C**
2. `TGPControls` are **AutoLayout**, `IB Designable` and `IB Inspectable` ready 2. `TGPControls` are **AutoLayout**, `IB Designable` and `IB Inspectable` ready
3. Version **5.0.1** and better comes with a **Swift 4** demo application for **iOS 8** and above. 3. Version **5.0.1** comes with a **Swift 4** demo application for **iOS 8** and above.
_**iOS 7** supported in versions 2.1.0 and earlier_ _**iOS 7** supported in versions 2.1.0 and earlier_
4. Automatic support for both left-to-right and right-to-left languages
![imagessliderdemo](https://cloud.githubusercontent.com/assets/4073988/6628373/183c7452-c8c2-11e4-9a63-107805bc0cc4.gif) ![imagessliderdemo](https://cloud.githubusercontent.com/assets/4073988/6628373/183c7452-c8c2-11e4-9a63-107805bc0cc4.gif)
@ -84,9 +82,7 @@ All graphic aspects, such as physical spacing of the ticks or physical width of
``` ```
discreteSlider.ticksListener = camelLabels discreteSlider.ticksListener = camelLabels
``` ```
![complete](https://cloud.githubusercontent.com/assets/4073988/5912616/26cf1b0a-a58b-11e4-92f7-f9dbcd53c413.gif) ![complete](https://cloud.githubusercontent.com/assets/4073988/5912616/26cf1b0a-a58b-11e4-92f7-f9dbcd53c413.gif)
That's all! That's all!
Through the `TGPControlsTicksProtocol`, the camelLabels listen to _value_ and _size_ changes. You may want to adopt this protocol to handle changes, or use the traditional `UIControl` notifications: Through the `TGPControlsTicksProtocol`, the camelLabels listen to _value_ and _size_ changes. You may want to adopt this protocol to handle changes, or use the traditional `UIControl` notifications:
@ -122,33 +118,27 @@ self.stepper.value = Double(sender.value)
| Tick | | | Tick | |
|:-----| ----- | |:-----| ----- |
| `tickStyle` | See style property |
| `tickSize` | absolute dimension | | `tickSize` | absolute dimension |
| `tickCount` | discrete steps, must be 2 or greater |
| `minimumTickTintColor` | lower side ticks ; takes precedence over `minimumTrackTintColor` (†1) |
| `maximumTickTintColor` | higher side ticks ; takes precedence over `maximumTrackTintColor` (†1) |
| `tickImage` | a `UIImage`, fits in `tickSize` (†) | | `tickImage` | a `UIImage`, fits in `tickSize` (†) |
| `tickCount` | discrete steps, must be 2 or greater |
| `ticksDistance` | horizontal spacing _(calculated)_ | | `ticksDistance` | horizontal spacing _(calculated)_ |
| Track | | | Track | |
|:------| ----- | |:------| ----- |
| `trackStyle` | See style property |
| `trackThickness` | height | | `trackThickness` | height |
| `trackImage` | a `UIImage`, ignores `trackThickness` (†2) | | `trackImage` | a `UIImage`, ignores `trackThickness` (†) |
| `minimumTrackTintColor` | track lower side | | `minimumTrackTintColor` | track lower side |
| `maximumTrackTintColor` | track higher side | | `maximumTrackTintColor` | track higher side |
| Thumb | | | Thumb | |
|:------| ----- | |:------| ----- |
| `thumbStyle` | See style property |
| `thumbSize` | absolute size | | `thumbSize` | absolute size |
| `thumbTintColor` | background |
| `thumbImage` | a`UIImage`, dictates `thumbSize` (†) | | `thumbImage` | a`UIImage`, dictates `thumbSize` (†) |
| `thumbTintColor` | background |
| `thumbShadowRadius` | breaking the _flat design concept_ | | `thumbShadowRadius` | breaking the _flat design concept_ |
| `thumbShadowOffset` | applied to `thumbShadowRadius`, may affect control bounds | | `thumbShadowOffset` | applied to `thumbShadowRadius`, may affect control bounds |
(†1) Introduced in 5.1.0. (†) Introduced in version 4.0.0. Former versions used a resource name as a `string`.
(†2) Introduced in 4.0.0. Former versions used a resource name as a `string`.
![image](https://cloud.githubusercontent.com/assets/4073988/5910789/e102af28-a572-11e4-9169-b18555e20eab.png) ![image](https://cloud.githubusercontent.com/assets/4073988/5910789/e102af28-a572-11e4-9169-b18555e20eab.png)
@ -169,9 +159,8 @@ Most of the customization can be done inside **Interface Builder**.
| Property | | | Property | |
|:---------| ----- | |:---------| ----- |
| `tickCount` | **design only** (_preferrably not to be used_): the number of ticks is driven by the number of elements in the `names` array |
| `names` | supplies a new set of labels ; supersedes the `tickCount` property, which will return the number of labels. A typical use may be `camelLabels.names = ["OFF", "ON"]` |
| `ticksListener` | ties a discrete slider to its camel labels. This is your most robust method to not only ensure that the layout of both controls match exactly, but also adjust this spacing when orientation changes. A typical use may be `discreteSlider.ticksListener = camelLabels` | | `ticksListener` | ties a discrete slider to its camel labels. This is your most robust method to not only ensure that the layout of both controls match exactly, but also adjust this spacing when orientation changes. A typical use may be `discreteSlider.ticksListener = camelLabels` |
| `names` | supplies a new set of labels ; supersedes the `tickCount` property, which will return the number of labels. A typical use may be `camelLabels.names = ["OFF", "ON"]` |
| `ticksDistance` | _override_ the labels spacing entirely ; **prefer** the `ticksListener` mechanism if it is available to you. A typical use may be `camelLabels.ticksDistance = 15` | | `ticksDistance` | _override_ the labels spacing entirely ; **prefer** the `ticksListener` mechanism if it is available to you. A typical use may be `camelLabels.ticksDistance = 15` |
| `value` | which label is emphasized (_selected_) | | `value` | which label is emphasized (_selected_) |
| `backgroundColor` | labels become *tap-through* (**click-through**) when set to `UIColor.clear` ; use TGPCamelLabels *on top of* other UI elements, **even native iOS objects**!(*) | | `backgroundColor` | labels become *tap-through* (**click-through**) when set to `UIColor.clear` ; use TGPCamelLabels *on top of* other UI elements, **even native iOS objects**!(*) |
@ -181,7 +170,6 @@ Most of the customization can be done inside **Interface Builder**.
| Edges & Animation | | | Edges & Animation | |
|:------------------| ----- | |:------------------| ----- |
| `numberOfLiness` | Support for multiple lines labels |
| `offCenter` | **leftmost and righmost labels only**: relative inset expressed as a proportion of individual label width: 0: none, +0.5: nudge in by a half width (fully fit) or -0.5: draw completely outside | | `offCenter` | **leftmost and righmost labels only**: relative inset expressed as a proportion of individual label width: 0: none, +0.5: nudge in by a half width (fully fit) or -0.5: draw completely outside |
| `insets` | **leftmost and righmost labels only**: absolute inset expressed in pixels | | `insets` | **leftmost and righmost labels only**: absolute inset expressed in pixels |
| `emphasisLayout` | emphasized (_selected_) labels vertical alignment ; `.top`, `.centerY` or `.bottom`. Default is `.top` (‡) | | `emphasisLayout` | emphasized (_selected_) labels vertical alignment ; `.top`, `.centerY` or `.bottom`. Default is `.top` (‡) |
@ -203,7 +191,7 @@ Most of the customization can be done inside **Interface Builder**.
--- ---
### Code example (Swift) ### Code example (Swift 3)
See **TGPControlsDemo** project: `TGPControlsDemo` (Modern Swift syntax + IBInspectable) See **TGPControlsDemo** project: `TGPControlsDemo` (Modern Swift syntax + IBInspectable)

View File

@ -2,7 +2,7 @@ Pod::Spec.new do |spec|
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
spec.name = "TGPControls" spec.name = "TGPControls"
spec.version = "5.1.0" spec.version = "5.0.2"
spec.summary = "Custom animated iOS controls: Animated discrete slider, animated labels" spec.summary = "Custom animated iOS controls: Animated discrete slider, animated labels"
spec.description = <<-DESC spec.description = <<-DESC
@ -26,7 +26,7 @@ Pod::Spec.new do |spec|
spec.swift_version = '4.0' spec.swift_version = '4.0'
# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
spec.source = { :git => "https://github.com/SwiftArchitect/TGPControls.git", :tag => "v5.1.0" } spec.source = { :git => "https://github.com/SwiftArchitect/TGPControls.git", :tag => "v5.0.2" }
spec.source_files = "TGPControls/**/*.{swift}" spec.source_files = "TGPControls/**/*.{swift}"
spec.exclude_files = "TGPControlsDemo/*" spec.exclude_files = "TGPControlsDemo/*"

View File

@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 50; objectVersion = 46;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
@ -110,7 +110,7 @@
}; };
}; };
buildConfigurationList = DC56BDF71E46EA2000AAD0D9 /* Build configuration list for PBXProject "TGPControls" */; buildConfigurationList = DC56BDF71E46EA2000AAD0D9 /* Build configuration list for PBXProject "TGPControls" */;
compatibilityVersion = "Xcode 9.3"; compatibilityVersion = "Xcode 3.2";
developmentRegion = English; developmentRegion = English;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
knownRegions = ( knownRegions = (
@ -199,6 +199,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
@ -254,10 +255,10 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_SWIFT3_OBJC_INFERENCE = Default;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
@ -278,11 +279,8 @@
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = TGPControls/Info.plist; INFOPLIST_FILE = TGPControls/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = ( IPHONEOS_DEPLOYMENT_TARGET = 8.0;
"$(inherited)", LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControls; PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControls;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
@ -304,11 +302,8 @@
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = TGPControls/Info.plist; INFOPLIST_FILE = TGPControls/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = ( IPHONEOS_DEPLOYMENT_TARGET = 8.0;
"$(inherited)", LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControls; PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControls;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;

View File

@ -78,11 +78,11 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER {
} }
} }
@IBInspectable public var numberOfLinesInLabel:Int = 1 { @IBInspectable public var numberOfLinesInLabel:Int = 1 {
didSet { didSet {
layoutTrack() layoutTrack()
} }
} }
// Label off-center to the left and right of the slider // Label off-center to the left and right of the slider
// expressed in label width. 0: none, -1/2: half outside, 1/2; half inside // expressed in label width. 0: none, -1/2: half outside, 1/2; half inside
@ -166,7 +166,6 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER {
var lastValue = NSNotFound var lastValue = NSNotFound
var emphasizedLabels:[UILabel] = [] var emphasizedLabels:[UILabel] = []
var regularLabels:[UILabel] = [] var regularLabels:[UILabel] = []
var localeCharacterDirection = CFLocaleLanguageDirection.leftToRight
// MARK: UIView // MARK: UIView
@ -196,11 +195,6 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER {
// MARK: TGPCamelLabels // MARK: TGPCamelLabels
func initProperties() { func initProperties() {
if let systemLocale = CFLocaleCopyCurrent(),
let localeIdentifier = CFLocaleGetIdentifier(systemLocale) {
localeCharacterDirection = CFLocaleGetLanguageCharacterDirection(localeIdentifier.rawValue)
}
debugNames(count: 10) debugNames(count: 10)
layoutTrack() layoutTrack()
} }
@ -240,16 +234,10 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER {
let count = names.count let count = names.count
if count > 0 { if count > 0 {
var centerX = (bounds.width - (CGFloat(count - 1) * ticksDistance))/2.0 var centerX = (bounds.width - (CGFloat(count - 1) * ticksDistance))/2.0
if .rightToLeft == localeCharacterDirection {
centerX = bounds.width - centerX
}
let tickSpacing = (.rightToLeft == localeCharacterDirection)
? -ticksDistance
: ticksDistance
let centerY = bounds.height / 2.0 let centerY = bounds.height / 2.0
for name in names { for name in names {
let upLabel = UILabel.init() let upLabel = UILabel.init()
upLabel.numberOfLines = numberOfLinesInLabel upLabel.numberOfLines = self.numberOfLinesInLabel
emphasizedLabels.append(upLabel) emphasizedLabels.append(upLabel)
upLabel.text = name upLabel.text = name
if let upFontName = upFontName { if let upFontName = upFontName {
@ -273,7 +261,7 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER {
addSubview(upLabel) addSubview(upLabel)
let dnLabel = UILabel.init() let dnLabel = UILabel.init()
dnLabel.numberOfLines = numberOfLinesInLabel dnLabel.numberOfLines = self.numberOfLinesInLabel
regularLabels.append(dnLabel) regularLabels.append(dnLabel)
dnLabel.text = name dnLabel.text = name
if let downFontName = downFontName { if let downFontName = downFontName {
@ -291,21 +279,15 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER {
}() }()
addSubview(dnLabel) addSubview(dnLabel)
centerX += tickSpacing centerX += ticksDistance
} }
// Fix left and right label, if there are at least 2 labels // Fix left and right label, if there are at least 2 labels
if names.count > 1 { if names.count > 1 {
let localeInsets = (.rightToLeft == localeCharacterDirection) insetLabel(emphasizedLabels.first, withInset: insets, andMultiplier: offCenter)
? -insets insetLabel(emphasizedLabels.last, withInset: -insets, andMultiplier: -offCenter)
: insets insetLabel(regularLabels.first, withInset: insets, andMultiplier: offCenter)
let localeOffCenter = (.rightToLeft == localeCharacterDirection) insetLabel(regularLabels.last, withInset: -insets, andMultiplier: -offCenter)
? -offCenter
: offCenter
insetLabel(emphasizedLabels.first, withInset: localeInsets, andMultiplier: localeOffCenter)
insetLabel(emphasizedLabels.last, withInset: -localeInsets, andMultiplier: -localeOffCenter)
insetLabel(regularLabels.first, withInset: localeInsets, andMultiplier: localeOffCenter)
insetLabel(regularLabels.last, withInset: -localeInsets, andMultiplier: -localeOffCenter)
} }
dockEffect(duration:0.0) dockEffect(duration:0.0)

View File

@ -41,13 +41,7 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
} }
} }
@IBInspectable public var minimumTickTintColor:UIColor? = nil { @IBInspectable public var tickTintColor:UIColor? = nil {
didSet {
layoutTrack()
}
}
@IBInspectable public var maximumTickTintColor:UIColor? = nil {
didSet { didSet {
layoutTrack() layoutTrack()
} }
@ -84,7 +78,7 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
} }
} }
@IBInspectable public var maximumTrackTintColor = UIColor(white: 0.71, alpha: 1) { @IBInspectable public var maximumTrackTintColor:UIColor = UIColor(white: 0.71, alpha: 1) {
didSet { didSet {
layoutTrack() layoutTrack()
} }
@ -214,6 +208,7 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
let segments = CGFloat(max(1, tickCount - 1)) let segments = CGFloat(max(1, tickCount - 1))
return trackRectangle.width / segments return trackRectangle.width / segments
} }
set {}
} }
@objc public var ticksListener:TGPControlsTicksProtocol? = nil { @objc public var ticksListener:TGPControlsTicksProtocol? = nil {
@ -226,25 +221,15 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
var intValue:Int = 0 var intValue:Int = 0
var intMinimumValue = -5 var intMinimumValue = -5
var ticksAbscissae:[CGPoint] = [] var ticksAbscisses:[CGPoint] = []
var thumbAbscissa:CGFloat = 0 var thumbAbscisse:CGFloat = 0
var thumbLayer = CALayer() var thumbLayer = CALayer()
var trackLayer = CALayer()
var leftTrackLayer = CALayer() var leftTrackLayer = CALayer()
var rightTrackLayer = CALayer() var rightTrackLayer = CALayer()
var leadingTrackLayer: CALayer! var trackLayer = CALayer()
var trailingTrackLayer: CALayer!
var ticksLayer = CALayer() var ticksLayer = CALayer()
var leftTicksLayer = CALayer()
var rightTicksLayer = CALayer()
var leadingTicksLayer: CALayer!
var trailingTicksLayer: CALayer!
var trackRectangle = CGRect.zero var trackRectangle = CGRect.zero
var touchedInside = false var touchedInside = false
var localeCharacterDirection = CFLocaleLanguageDirection.leftToRight
let iOSThumbShadowRadius:CGFloat = 4 let iOSThumbShadowRadius:CGFloat = 4
let iOSThumbShadowOffset = CGSize(width:0, height:3) let iOSThumbShadowOffset = CGSize(width:0, height:3)
@ -277,38 +262,19 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
// MARK: TGPDiscreteSlider // MARK: TGPDiscreteSlider
func initProperties() { func initProperties() {
if let systemLocale = CFLocaleCopyCurrent(), // Track is a clear clipping layer, and left + right sublayers, which brings in free animation
let localeIdentifier = CFLocaleGetIdentifier(systemLocale) {
localeCharacterDirection = CFLocaleGetLanguageCharacterDirection(localeIdentifier.rawValue)
}
leadingTrackLayer = (.rightToLeft == localeCharacterDirection)
? rightTrackLayer
: leftTrackLayer
trailingTrackLayer = (.rightToLeft == localeCharacterDirection)
? leftTrackLayer
: rightTrackLayer
leadingTicksLayer = (.rightToLeft == localeCharacterDirection)
? rightTicksLayer
: leftTicksLayer
trailingTicksLayer = (.rightToLeft == localeCharacterDirection)
? leftTicksLayer
: rightTicksLayer
// Track and ticks are in a clear clipping layer, and left + right sublayers,
// which brings in free animation
trackLayer.masksToBounds = true trackLayer.masksToBounds = true
trackLayer.backgroundColor = UIColor.clear.cgColor trackLayer.backgroundColor = UIColor.clear.cgColor
layer.addSublayer(trackLayer) layer.addSublayer(trackLayer)
if let backgroundColor = tintColor {
leftTrackLayer.backgroundColor = backgroundColor.cgColor
}
trackLayer.addSublayer(leftTrackLayer) trackLayer.addSublayer(leftTrackLayer)
rightTrackLayer.backgroundColor = maximumTrackTintColor.cgColor
trackLayer.addSublayer(rightTrackLayer) trackLayer.addSublayer(rightTrackLayer)
// Ticks in between track and thumb // Ticks in between track and thumb
ticksLayer.masksToBounds = true
ticksLayer.backgroundColor = UIColor.clear.cgColor
layer.addSublayer(ticksLayer) layer.addSublayer(ticksLayer)
ticksLayer.addSublayer(rightTicksLayer) // reverse order, left covers right
ticksLayer.addSublayer(leftTicksLayer)
// The thumb is its own CALayer, which brings in free animation // The thumb is its own CALayer, which brings in free animation
layer.addSublayer(thumbLayer) layer.addSublayer(thumbLayer)
@ -319,6 +285,11 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
func drawTicks() { func drawTicks() {
ticksLayer.frame = bounds ticksLayer.frame = bounds
if let tickColor = tickTintColor ?? tintColor {
ticksLayer.backgroundColor = tickColor.cgColor
}
let path = UIBezierPath() let path = UIBezierPath()
switch tickComponentStyle { switch tickComponentStyle {
@ -329,7 +300,7 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
fallthrough fallthrough
case .image: case .image:
for originPoint in ticksAbscissae { for originPoint in ticksAbscisses {
let rectangle = CGRect(x: originPoint.x-(tickSize.width/2), let rectangle = CGRect(x: originPoint.x-(tickSize.width/2),
y: originPoint.y-(tickSize.height/2), y: originPoint.y-(tickSize.height/2),
width: tickSize.width, width: tickSize.width,
@ -377,35 +348,10 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
break break
} }
leftTicksLayer.frame = { let maskLayer = CAShapeLayer()
var frame = ticksLayer.bounds maskLayer.frame = trackLayer.bounds
let tickWidth = (.rightToLeft == localeCharacterDirection) maskLayer.path = path.cgPath
? -tickSize.width/2 ticksLayer.mask = maskLayer
: tickSize.width/2
frame.size.width = tickWidth + thumbAbscissa
return frame
}()
leftTicksLayer.mask = {
let maskLayer = CAShapeLayer()
maskLayer.frame = ticksLayer.bounds
maskLayer.path = path.cgPath
return maskLayer
}()
rightTicksLayer.frame = ticksLayer.bounds
rightTicksLayer.mask = {
let maskLayer = CAShapeLayer()
maskLayer.path = path.cgPath
return maskLayer
}()
if let backgroundColor = minimumTickTintColor ?? (minimumTrackTintColor ?? tintColor) {
leadingTicksLayer.backgroundColor = backgroundColor.cgColor
}
trailingTicksLayer.backgroundColor = maximumTickTintColor?.cgColor ?? maximumTrackTintColor.cgColor
} }
func drawTrack() { func drawTrack() {
@ -424,7 +370,11 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
if let image = trackImage, if let image = trackImage,
let cgImage = image.cgImage, let cgImage = image.cgImage,
let ctx = UIGraphicsGetCurrentContext() { let ctx = UIGraphicsGetCurrentContext() {
ctx.draw(cgImage, in: trackRectangle) let centered = CGRect(x: (frame.width/2) - (image.size.width/2),
y: (frame.height/2) - (image.size.height/2),
width: image.size.width,
height: image.size.height)
ctx.draw(cgImage, in: centered)
} }
case .rounded: case .rounded:
@ -441,21 +391,21 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
leftTrackLayer.frame = { leftTrackLayer.frame = {
var frame = trackLayer.bounds var frame = trackLayer.bounds
frame.size.width = thumbAbscissa - trackRectangle.minX frame.size.width = thumbAbscisse - trackRectangle.minX
return frame return frame
}() }()
if let backgroundColor = minimumTrackTintColor ?? tintColor {
leftTrackLayer.backgroundColor = backgroundColor.cgColor
}
rightTrackLayer.frame = { rightTrackLayer.frame = {
var frame = trackLayer.bounds var frame = trackLayer.bounds
frame.size.width = trackRectangle.width - leftTrackLayer.frame.width frame.size.width = trackRectangle.width - leftTrackLayer.frame.width
frame.origin.x = leftTrackLayer.frame.maxX frame.origin.x = leftTrackLayer.frame.maxX
return frame return frame
}() }()
rightTrackLayer.backgroundColor = maximumTrackTintColor.cgColor
if let backgroundColor = minimumTrackTintColor ?? tintColor {
leadingTrackLayer.backgroundColor = backgroundColor.cgColor
}
trailingTrackLayer.backgroundColor = maximumTrackTintColor.cgColor
} }
func drawThumb() { func drawThumb() {
@ -464,13 +414,19 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
let thumbSizeForStyle = thumbSizeIncludingShadow() let thumbSizeForStyle = thumbSizeIncludingShadow()
let thumbWidth = thumbSizeForStyle.width let thumbWidth = thumbSizeForStyle.width
let thumbHeight = thumbSizeForStyle.height let thumbHeight = thumbSizeForStyle.height
let rectangle = CGRect(x:thumbAbscisse - (thumbWidth / 2),
y: (frame.height - thumbHeight)/2,
width: thumbWidth,
height: thumbHeight)
let shadowRadius = (thumbComponentStyle == .iOS) ? iOSThumbShadowRadius : thumbShadowRadius let shadowRadius = (thumbComponentStyle == .iOS) ? iOSThumbShadowRadius : thumbShadowRadius
let shadowOffset = (thumbComponentStyle == .iOS) ? iOSThumbShadowOffset : thumbShadowOffset let shadowOffset = (thumbComponentStyle == .iOS) ? iOSThumbShadowOffset : thumbShadowOffset
thumbLayer.frame = CGRect(x:thumbAbscissa - (thumbWidth / 2), thumbLayer.frame = ((shadowRadius != 0.0) // Ignore offset if there is no shadow
y: (frame.height - thumbHeight)/2, ? rectangle.insetBy(dx: shadowRadius + shadowOffset.width,
width: thumbWidth, dy: shadowRadius + shadowOffset.height)
height: thumbHeight) : rectangle.insetBy(dx: shadowRadius,
dy: shadowRadius))
switch thumbComponentStyle { switch thumbComponentStyle {
case .rounded: // A rounded thumb is circular case .rounded: // A rounded thumb is circular
@ -548,17 +504,22 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
let trackHeight = (.iOS == trackComponentStyle) ? 2 : trackThickness let trackHeight = (.iOS == trackComponentStyle) ? 2 : trackThickness
var trackSize = CGSize(width: frame.width - thumbWidth, var trackSize = CGSize(width: frame.width - thumbWidth,
height: trackHeight) height: trackHeight)
if(.image == trackComponentStyle) {
if let image = trackImage {
trackSize.width = image.size.width - thumbWidth
}
}
trackRectangle = CGRect(x: (frame.width - trackSize.width)/2, trackRectangle = CGRect(x: (frame.width - trackSize.width)/2,
y: (frame.height - trackSize.height)/2, y: (frame.height - trackSize.height)/2,
width: trackSize.width, width: trackSize.width,
height: trackSize.height) height: trackSize.height)
let trackY = frame.height / 2 let trackY = frame.height / 2
ticksAbscissae = [] ticksAbscisses = []
for iterate in 0 ... segments { for iterate in 0 ... segments {
let ratio = Double(iterate) / Double(segments) let ratio = Double(iterate) / Double(segments)
let originX = trackRectangle.origin.x + (CGFloat)(trackSize.width * CGFloat(ratio)) let originX = trackRectangle.origin.x + (CGFloat)(trackSize.width * CGFloat(ratio))
ticksAbscissae.append(CGPoint(x: originX, y: trackY)) ticksAbscisses.append(CGPoint(x: originX, y: trackY))
} }
layoutThumb() layoutThumb()
@ -575,10 +536,7 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
let nonZeroIncrement = ((0 == incrementValue) ? 1 : incrementValue) let nonZeroIncrement = ((0 == incrementValue) ? 1 : incrementValue)
var thumbRatio = Double(value - minimumValue) / Double(segments * nonZeroIncrement) var thumbRatio = Double(value - minimumValue) / Double(segments * nonZeroIncrement)
thumbRatio = max(0.0, min(thumbRatio, 1.0)) // Normalized thumbRatio = max(0.0, min(thumbRatio, 1.0)) // Normalized
thumbRatio = (.rightToLeft == localeCharacterDirection) thumbAbscisse = trackRectangle.origin.x + (CGFloat)(trackRectangle.width * CGFloat(thumbRatio))
? 1.0 - thumbRatio
: thumbRatio
thumbAbscissa = trackRectangle.origin.x + (CGFloat)(trackRectangle.width * CGFloat(thumbRatio))
} }
func thumbSizeIncludingShadow() -> CGSize { func thumbSizeIncludingShadow() -> CGSize {
@ -670,14 +628,14 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
func touchDown(_ touches: Set<UITouch>, animationDuration duration:TimeInterval) { func touchDown(_ touches: Set<UITouch>, animationDuration duration:TimeInterval) {
if let touch = touches.first { if let touch = touches.first {
let location = touch.location(in: touch.view) let location = touch.location(in: touch.view)
moveThumbTo(abscissa: location.x, animationDuration: duration) moveThumbTo(abscisse: location.x, animationDuration: duration)
} }
} }
func touchUp(_ touches: Set<UITouch>) { func touchUp(_ touches: Set<UITouch>) {
if let touch = touches.first { if let touch = touches.first {
let location = touch.location(in: touch.view) let location = touch.location(in: touch.view)
let tick = pickTickFromSliderPosition(abscissa: location.x) let tick = pickTickFromSliderPosition(abscisse: location.x)
moveThumbToTick(tick: tick) moveThumbToTick(tick: tick)
} }
} }
@ -707,14 +665,14 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
setNeedsDisplay() setNeedsDisplay()
} }
func moveThumbTo(abscissa:CGFloat, animationDuration duration:TimeInterval) { func moveThumbTo(abscisse:CGFloat, animationDuration duration:TimeInterval) {
let leftMost = trackRectangle.minX let leftMost = trackRectangle.minX
let rightMost = trackRectangle.maxX let rightMost = trackRectangle.maxX
thumbAbscissa = max(leftMost, min(abscissa, rightMost)) thumbAbscisse = max(leftMost, min(abscisse, rightMost))
CATransaction.setAnimationDuration(duration) CATransaction.setAnimationDuration(duration)
let tick = pickTickFromSliderPosition(abscissa: thumbAbscissa) let tick = pickTickFromSliderPosition(abscisse: thumbAbscisse)
let nonZeroIncrement = ((0 == incrementValue) ? 1 : incrementValue) let nonZeroIncrement = ((0 == incrementValue) ? 1 : incrementValue)
let intValue = Int(minimumValue) + (Int(tick) * nonZeroIncrement) let intValue = Int(minimumValue) + (Int(tick) * nonZeroIncrement)
if intValue != self.intValue { if intValue != self.intValue {
@ -725,14 +683,11 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
setNeedsDisplay() setNeedsDisplay()
} }
func pickTickFromSliderPosition(abscissa: CGFloat) -> UInt { func pickTickFromSliderPosition(abscisse: CGFloat) -> UInt {
let leftMost = trackRectangle.minX let leftMost = trackRectangle.minX
let rightMost = trackRectangle.maxX let rightMost = trackRectangle.maxX
let clampedAbscissa = max(leftMost, min(abscissa, rightMost)) let clampedAbscisse = max(leftMost, min(abscisse, rightMost))
var ratio = Double(clampedAbscissa - leftMost) / Double(rightMost - leftMost) let ratio = Double(clampedAbscisse - leftMost) / Double(rightMost - leftMost)
ratio = (.rightToLeft == localeCharacterDirection)
? 1.0 - ratio
: ratio
let segments = max(1, tickCount - 1) let segments = max(1, tickCount - 1)
return UInt(round( Double(segments) * ratio)) return UInt(round( Double(segments) * ratio))
} }

View File

@ -3,23 +3,8 @@ platform :ios, '8.0'
use_frameworks! use_frameworks!
target 'TGPControlsDemo-Pods' do target 'TGPControlsDemo-Pods' do
#pod 'TGPControls', :path => '../../TGPControls' pod 'TGPControls', :path => '../../TGPControls'
pod 'TGPControls' #pod 'TGPControls'
end end
# Failed to render and update auto layout status for UIViewController : dlopen(Cosmos.framework, 1): no suitable image found
# https://github.com/CocoaPods/CocoaPods/issues/7606#issuecomment-381279098
# https://stackoverflow.com/a/49936237/218152
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end

View File

@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 50; objectVersion = 46;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
@ -20,10 +20,6 @@
DC56BDCC1E46DEB900AAD0D9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC56BDCA1E46DEB900AAD0D9 /* Main.storyboard */; }; DC56BDCC1E46DEB900AAD0D9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC56BDCA1E46DEB900AAD0D9 /* Main.storyboard */; };
DC56BDCE1E46DEB900AAD0D9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC56BDCD1E46DEB900AAD0D9 /* Assets.xcassets */; }; DC56BDCE1E46DEB900AAD0D9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC56BDCD1E46DEB900AAD0D9 /* Assets.xcassets */; };
DC56BDD11E46DEB900AAD0D9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC56BDCF1E46DEB900AAD0D9 /* LaunchScreen.storyboard */; }; DC56BDD11E46DEB900AAD0D9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC56BDCF1E46DEB900AAD0D9 /* LaunchScreen.storyboard */; };
DC7677B820C5C5BA006155F3 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = DC7677B620C5C5BA006155F3 /* Localizable.strings */; };
DC7677B920C5C5BA006155F3 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = DC7677B620C5C5BA006155F3 /* Localizable.strings */; };
DC7677BD20C5C712006155F3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DC7677BB20C5C712006155F3 /* InfoPlist.strings */; };
DC7677BE20C5C712006155F3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DC7677BB20C5C712006155F3 /* InfoPlist.strings */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
@ -54,11 +50,6 @@
DC56BDCD1E46DEB900AAD0D9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; DC56BDCD1E46DEB900AAD0D9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
DC56BDD01E46DEB900AAD0D9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; DC56BDD01E46DEB900AAD0D9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
DC56BDD21E46DEB900AAD0D9 /* TGPControlsDemo-Pods-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TGPControlsDemo-Pods-Info.plist"; sourceTree = "<group>"; }; DC56BDD21E46DEB900AAD0D9 /* TGPControlsDemo-Pods-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TGPControlsDemo-Pods-Info.plist"; sourceTree = "<group>"; };
DC7677B720C5C5BA006155F3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
DC7677BA20C5C5E5006155F3 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
DC7677BC20C5C712006155F3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/InfoPlist.strings; sourceTree = "<group>"; };
DC7677BF20C5C769006155F3 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/InfoPlist.strings; sourceTree = "<group>"; };
DCEE05AD20C20D650081CD34 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Main.strings; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -128,8 +119,6 @@
DC56BDCF1E46DEB900AAD0D9 /* LaunchScreen.storyboard */, DC56BDCF1E46DEB900AAD0D9 /* LaunchScreen.storyboard */,
DC56BDD21E46DEB900AAD0D9 /* TGPControlsDemo-Pods-Info.plist */, DC56BDD21E46DEB900AAD0D9 /* TGPControlsDemo-Pods-Info.plist */,
DC4FF6511EA2E08C00BBF8E4 /* TGPControlsDemo-Cart-Info.plist */, DC4FF6511EA2E08C00BBF8E4 /* TGPControlsDemo-Cart-Info.plist */,
DC7677B620C5C5BA006155F3 /* Localizable.strings */,
DC7677BB20C5C712006155F3 /* InfoPlist.strings */,
); );
path = TGPControlsDemo; path = TGPControlsDemo;
sourceTree = "<group>"; sourceTree = "<group>";
@ -164,6 +153,7 @@
DC56BDC01E46DEB900AAD0D9 /* Frameworks */, DC56BDC01E46DEB900AAD0D9 /* Frameworks */,
DC56BDC11E46DEB900AAD0D9 /* Resources */, DC56BDC11E46DEB900AAD0D9 /* Resources */,
A772C50843047EE677ADAF15 /* [CP] Embed Pods Frameworks */, A772C50843047EE677ADAF15 /* [CP] Embed Pods Frameworks */,
3FF2E09CAFA7D92A488FACF7 /* [CP] Copy Pods Resources */,
); );
buildRules = ( buildRules = (
); );
@ -192,13 +182,12 @@
}; };
}; };
buildConfigurationList = DC56BDBE1E46DEB900AAD0D9 /* Build configuration list for PBXProject "TGPControlsDemo" */; buildConfigurationList = DC56BDBE1E46DEB900AAD0D9 /* Build configuration list for PBXProject "TGPControlsDemo" */;
compatibilityVersion = "Xcode 9.3"; compatibilityVersion = "Xcode 3.2";
developmentRegion = English; developmentRegion = English;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
knownRegions = ( knownRegions = (
en, en,
Base, Base,
ar,
); );
mainGroup = DC56BDBA1E46DEB900AAD0D9; mainGroup = DC56BDBA1E46DEB900AAD0D9;
productRefGroup = DC56BDC41E46DEB900AAD0D9 /* Products */; productRefGroup = DC56BDC41E46DEB900AAD0D9 /* Products */;
@ -217,10 +206,8 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
DC4FF6481EA2E08C00BBF8E4 /* LaunchScreen.storyboard in Resources */, DC4FF6481EA2E08C00BBF8E4 /* LaunchScreen.storyboard in Resources */,
DC7677B920C5C5BA006155F3 /* Localizable.strings in Resources */,
DC4FF6491EA2E08C00BBF8E4 /* Assets.xcassets in Resources */, DC4FF6491EA2E08C00BBF8E4 /* Assets.xcassets in Resources */,
DC4FF64A1EA2E08C00BBF8E4 /* Main.storyboard in Resources */, DC4FF64A1EA2E08C00BBF8E4 /* Main.storyboard in Resources */,
DC7677BE20C5C712006155F3 /* InfoPlist.strings in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -229,10 +216,8 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
DC56BDD11E46DEB900AAD0D9 /* LaunchScreen.storyboard in Resources */, DC56BDD11E46DEB900AAD0D9 /* LaunchScreen.storyboard in Resources */,
DC7677B820C5C5BA006155F3 /* Localizable.strings in Resources */,
DC56BDCE1E46DEB900AAD0D9 /* Assets.xcassets in Resources */, DC56BDCE1E46DEB900AAD0D9 /* Assets.xcassets in Resources */,
DC56BDCC1E46DEB900AAD0D9 /* Main.storyboard in Resources */, DC56BDCC1E46DEB900AAD0D9 /* Main.storyboard in Resources */,
DC7677BD20C5C712006155F3 /* InfoPlist.strings in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -257,6 +242,21 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
3FF2E09CAFA7D92A488FACF7 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TGPControlsDemo-Pods/Pods-TGPControlsDemo-Pods-resources.sh\"\n";
showEnvVarsInLog = 0;
};
A772C50843047EE677ADAF15 /* [CP] Embed Pods Frameworks */ = { A772C50843047EE677ADAF15 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -303,7 +303,6 @@
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (
DC56BDCB1E46DEB900AAD0D9 /* Base */, DC56BDCB1E46DEB900AAD0D9 /* Base */,
DCEE05AD20C20D650081CD34 /* ar */,
); );
name = Main.storyboard; name = Main.storyboard;
sourceTree = "<group>"; sourceTree = "<group>";
@ -316,24 +315,6 @@
name = LaunchScreen.storyboard; name = LaunchScreen.storyboard;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
DC7677B620C5C5BA006155F3 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
DC7677B720C5C5BA006155F3 /* Base */,
DC7677BA20C5C5E5006155F3 /* ar */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
DC7677BB20C5C712006155F3 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
DC7677BC20C5C712006155F3 /* Base */,
DC7677BF20C5C769006155F3 /* ar */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */ /* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */ /* Begin XCBuildConfiguration section */
@ -348,10 +329,7 @@
"$(PROJECT_DIR)/Carthage/Build/iOS", "$(PROJECT_DIR)/Carthage/Build/iOS",
); );
INFOPLIST_FILE = "$(SRCROOT)/TGPControlsDemo/TGPControlsDemo-Cart-Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/TGPControlsDemo/TGPControlsDemo-Cart-Info.plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControlsDemo; PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControlsDemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.0;
@ -369,10 +347,7 @@
"$(PROJECT_DIR)/Carthage/Build/iOS", "$(PROJECT_DIR)/Carthage/Build/iOS",
); );
INFOPLIST_FILE = "$(SRCROOT)/TGPControlsDemo/TGPControlsDemo-Cart-Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/TGPControlsDemo/TGPControlsDemo-Cart-Info.plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControlsDemo; PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControlsDemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.0;
@ -384,7 +359,6 @@
buildSettings = { buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
@ -445,7 +419,6 @@
buildSettings = { buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
@ -487,8 +460,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
@ -503,10 +475,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/TGPControlsDemo/TGPControlsDemo-Pods-Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/TGPControlsDemo/TGPControlsDemo-Pods-Info.plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControlsDemo; PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControlsDemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_SWIFT3_OBJC_INFERENCE = Default;
@ -522,10 +491,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/TGPControlsDemo/TGPControlsDemo-Pods-Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/TGPControlsDemo/TGPControlsDemo-Pods-Info.plist";
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControlsDemo; PRODUCT_BUNDLE_IDENTIFIER = com.swiftarchitect.TGPControlsDemo;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_SWIFT3_OBJC_INFERENCE = Default;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 B

After

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,2 +0,0 @@
"CFBundleDisplayName" = "TGPControls";
"NSHumanReadableCopyright" = "2016 Xavier Schott";

View File

@ -1,15 +0,0 @@
"oneTo10Labels.numbers" = "1 2 3 4 5 6 7 8 9 10";
"alphabetLabels.letters" = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z";
"pictureLabels.east" = "orient";
"pictureLabels.west" = "occident";
"pictureLabels.up" = "zénith";
"pictureLabels.down" = "nadir";
"pictureLabels.north" = "septentrion";
"pictureLabels.south" = "midi";
"switch1Camel.off" = "OFF";
"switch1Camel.on" = "ON";
"switch2Camel.off" = "O";
"switch2Camel.on" = "l";

View File

@ -379,12 +379,6 @@
<userDefinedRuntimeAttribute type="size" keyPath="thumbShadowOffset"> <userDefinedRuntimeAttribute type="size" keyPath="thumbShadowOffset">
<size key="value" width="0.0" height="0.0"/> <size key="value" width="0.0" height="0.0"/>
</userDefinedRuntimeAttribute> </userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="minimumTickTintColor">
<color key="value" red="0.85098039219999999" green="0.0" blue="0.1058823529" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="maximumTickTintColor">
<color key="value" red="0.85098039219999999" green="0.49424107142857143" blue="0.1058823529" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes> </userDefinedRuntimeAttributes>
</view> </view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="UIControlActions" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gID-5d-KDe"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="UIControlActions" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gID-5d-KDe">

View File

@ -4,8 +4,6 @@
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key>
<string>TGPControls</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
@ -17,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.0.3</string> <string>4.0.0</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@ -4,8 +4,6 @@
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key>
<string>TGPControls</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
@ -17,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>5.0.3</string> <string>4.0.0</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@ -18,35 +18,14 @@ class ViewController: UIViewController {
@IBOutlet weak var dualColorSlider: TGPDiscreteSlider! @IBOutlet weak var dualColorSlider: TGPDiscreteSlider!
@IBOutlet weak var stepper: UIStepper! @IBOutlet weak var stepper: UIStepper!
private func localizedStrings(_ key: String) -> [String] {
return NSLocalizedString(key, comment: "")
.split(separator: " ")
.map({ (substring) -> String in
return "\(substring)"
})
}
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
oneTo10Labels.names = localizedStrings("oneTo10Labels.numbers") alphabetLabels.names = ["A","B","C","D","E","F", "G","H","I","J","K","L","M",
"N","O","P","Q","R","S", "T","U","V","W","X","Y","Z"]
alphabetLabels.names = localizedStrings("alphabetLabels.letters") pictureLabels.names = ["orient", "occident", "zénith", "nadir", "septentrion", "midi"]
alphabetSlider.tickCount = alphabetLabels.names.count // Number of letters in the given alphabet switch1Camel.names = ["OFF", "ON"]
switch2Camel.names = ["O", "l"]
pictureLabels.names = [NSLocalizedString("pictureLabels.east", comment: ""),
NSLocalizedString("pictureLabels.west", comment: ""),
NSLocalizedString("pictureLabels.up", comment: ""),
NSLocalizedString("pictureLabels.down", comment: ""),
NSLocalizedString("pictureLabels.north", comment: ""),
NSLocalizedString("pictureLabels.south", comment: "")]
switch1Camel.names = [NSLocalizedString("switch1Camel.off", comment: ""),
NSLocalizedString("switch1Camel.on", comment: "")]
switch2Camel.names = [NSLocalizedString("switch2Camel.off", comment: ""),
NSLocalizedString("switch2Camel.on", comment: "")]
// Automatically track tick spacing changes and UIControlEventValueChanged // Automatically track tick spacing changes and UIControlEventValueChanged
alphabetSlider.ticksListener = alphabetLabels alphabetSlider.ticksListener = alphabetLabels

View File

@ -1,2 +0,0 @@
"CFBundleDisplayName" = "مراقبةTGP";
"NSHumanReadableCopyright" = "2016 Xavier Schott";

View File

@ -1,15 +0,0 @@
"oneTo10Labels.numbers" = "١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩ ١٠";
"alphabetLabels.letters" = "ا ب ج د ه و ز ح ط ي ك ل م ن س ع ف ص ق ر ش ت ث خ ذ ض ظ غ";
"pictureLabels.east" = "الشرق";
"pictureLabels.west" = "غرب";
"pictureLabels.up" = "إلى فوق";
"pictureLabels.down" = "نزولا";
"pictureLabels.north" = "شمال";
"pictureLabels.south" = "جنوب";
"switch1Camel.off" = "اطفاء";
"switch1Camel.on" = "تشغيل";
"switch2Camel.off" = "٠";
"switch2Camel.on" = "١";

View File

@ -1,15 +0,0 @@
/* Class = "UILabel"; text = "Layers and transparency"; ObjectID = "1wG-kf-nie"; */
"1wG-kf-nie.text" = "Layers and transparency";
/* Class = "UILabel"; text = "CamelLabels + Switch"; ObjectID = "A6t-OF-SSy"; */
"A6t-OF-SSy.text" = "CamelLabels + Switch";
/* Class = "UILabel"; text = "Variations"; ObjectID = "XPd-Af-CYy"; */
"XPd-Af-CYy.text" = "Variations";
/* Class = "UILabel"; text = "UIControlActions"; ObjectID = "gID-5d-KDe"; */
"gID-5d-KDe.text" = "UIControlActions";
/* Class = "UILabel"; text = "DiscreteSlider + CamelLabels"; ObjectID = "hED-uQ-kcm"; */
"hED-uQ-kcm.text" = "DiscreteSlider + CamelLabels";