Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 4.2 and Carthage support #67

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
22 changes: 22 additions & 0 deletions Info.plist
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>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

iOS7 style drop in replacement for UISwitch


![Animation](https://raw.github.com/bvogelzang/SevenSwitch/master/ExampleImages/example.gif)

![Default](https://raw.github.com/bvogelzang/SevenSwitch/master/ExampleImages/example.png)

## Usage

### Carthage

```
github "bvogelzang/SevenSwitch" ~> 2.2
```

### Cocoapods

```
Expand Down
4 changes: 2 additions & 2 deletions SevenSwitch.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SevenSwitch",
"version": "2.1.0",
"version": "2.2.0",
"summary": "iOS7 style drop in replacement for UISwitch.",
"homepage": "https://github.com/bvogelzang/SevenSwitch",
"screenshots": [
Expand All @@ -16,7 +16,7 @@
},
"source": {
"git": "https://github.com/bvogelzang/SevenSwitch.git",
"tag": "2.1.0"
"tag": "2.2.0"
},
"platforms": {
"ios": "8.0"
Expand Down
16 changes: 8 additions & 8 deletions SevenSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ import QuartzCore
// on/off images
self.onImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: self.frame.size.width - self.frame.size.height, height: self.frame.size.height))
onImageView.alpha = 1.0
onImageView.contentMode = UIViewContentMode.center
onImageView.contentMode = UIView.ContentMode.center
backgroundView.addSubview(onImageView)

self.offImageView = UIImageView(frame: CGRect(x: self.frame.size.height, y: 0, width: self.frame.size.width - self.frame.size.height, height: self.frame.size.height))
offImageView.alpha = 1.0
offImageView.contentMode = UIViewContentMode.center
offImageView.contentMode = UIView.ContentMode.center
backgroundView.addSubview(offImageView)

// labels
Expand Down Expand Up @@ -277,8 +277,8 @@ import QuartzCore

// thumb image
self.thumbImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: thumbView.frame.size.width, height: thumbView.frame.size.height))
thumbImageView.contentMode = UIViewContentMode.center
thumbImageView.autoresizingMask = UIViewAutoresizing.flexibleWidth
thumbImageView.contentMode = UIView.ContentMode.center
thumbImageView.autoresizingMask = UIView.AutoresizingMask.flexibleWidth
thumbView.addSubview(thumbImageView)

self.on = false
Expand All @@ -293,7 +293,7 @@ import QuartzCore
let activeKnobWidth = self.bounds.size.height - 2 + 5
isAnimating = true

UIView.animate(withDuration: 0.3, delay: 0.0, options: [UIViewAnimationOptions.curveEaseOut, UIViewAnimationOptions.beginFromCurrentState], animations: {
UIView.animate(withDuration: 0.3, delay: 0.0, options: [UIView.AnimationOptions.curveEaseOut, UIView.AnimationOptions.beginFromCurrentState], animations: {
if self.on {
self.thumbView.frame = CGRect(x: self.bounds.size.width - (activeKnobWidth + 1), y: self.thumbView.frame.origin.y, width: activeKnobWidth, height: self.thumbView.frame.size.height)
self.backgroundView.backgroundColor = self.onTintColor
Expand Down Expand Up @@ -355,7 +355,7 @@ import QuartzCore
}

if previousValue != self.on {
self.sendActions(for: UIControlEvents.valueChanged)
self.sendActions(for: UIControl.Event.valueChanged)
}
}

Expand Down Expand Up @@ -435,7 +435,7 @@ import QuartzCore
let activeKnobWidth = normalKnobWidth + 5
if animated {
isAnimating = true
UIView.animate(withDuration: 0.3, delay: 0.0, options: [UIViewAnimationOptions.curveEaseOut, UIViewAnimationOptions.beginFromCurrentState], animations: {
UIView.animate(withDuration: 0.3, delay: 0.0, options: [UIView.AnimationOptions.curveEaseOut, UIView.AnimationOptions.beginFromCurrentState], animations: {
if self.isTracking {
self.thumbView.frame = CGRect(x: self.bounds.size.width - (activeKnobWidth + 1), y: self.thumbView.frame.origin.y, width: activeKnobWidth, height: self.thumbView.frame.size.height)
}
Expand Down Expand Up @@ -491,7 +491,7 @@ import QuartzCore

if animated {
isAnimating = true
UIView.animate(withDuration: 0.3, delay: 0.0, options: [UIViewAnimationOptions.curveEaseOut, UIViewAnimationOptions.beginFromCurrentState], animations: {
UIView.animate(withDuration: 0.3, delay: 0.0, options: [UIView.AnimationOptions.curveEaseOut, UIView.AnimationOptions.beginFromCurrentState], animations: {
if self.isTracking {
self.thumbView.frame = CGRect(x: 1, y: self.thumbView.frame.origin.y, width: activeKnobWidth, height: self.thumbView.frame.size.height);
self.backgroundView.backgroundColor = self.activeColor
Expand Down
Loading