Commit 13691a94 by Daniel Dahan

updated MaterialSwitch to allow property setting for switchState

parent 3e1dc4a4
......@@ -11,8 +11,8 @@
96A71ED71C6FFF7300C0C4AE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71ED61C6FFF7300C0C4AE /* ViewController.swift */; };
96A71EDC1C6FFF7300C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71EDB1C6FFF7300C0C4AE /* Assets.xcassets */; };
96A71EDF1C6FFF7300C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71EDD1C6FFF7300C0C4AE /* LaunchScreen.storyboard */; };
96A720071C76D75100C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A720061C76D75100C0C4AE /* Material.framework */; };
96A720081C76D75100C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A720061C76D75100C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96A7200F1C777D0F00C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A7200E1C777D0F00C0C4AE /* Material.framework */; };
96A720101C777D0F00C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A7200E1C777D0F00C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -22,7 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96A720081C76D75100C0C4AE /* Material.framework in Embed Frameworks */,
96A720101C777D0F00C0C4AE /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -36,7 +36,7 @@
96A71EDB1C6FFF7300C0C4AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96A71EDE1C6FFF7300C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96A71EE01C6FFF7300C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96A720061C76D75100C0C4AE /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
96A7200E1C777D0F00C0C4AE /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -44,7 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96A720071C76D75100C0C4AE /* Material.framework in Frameworks */,
96A7200F1C777D0F00C0C4AE /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -54,7 +54,7 @@
96A71EC81C6FFF7300C0C4AE = {
isa = PBXGroup;
children = (
96A720061C76D75100C0C4AE /* Material.framework */,
96A7200E1C777D0F00C0C4AE /* Material.framework */,
96A71ED31C6FFF7300C0C4AE /* MaterialSwitch */,
96A71ED21C6FFF7300C0C4AE /* Products */,
);
......
......@@ -73,7 +73,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
c2 = MaterialSwitch(state: .Off, style: .LightContent)
c2.delegate = self
c2.translatesAutoresizingMaskIntoConstraints = false
c2.switchState = .On
topView.addSubview(c2)
let c3: MaterialSwitch = MaterialSwitch(state: .Off, style: .LightContent, size: .Large)
......@@ -114,7 +113,6 @@ class ViewController: UIViewController, MaterialSwitchDelegate {
internal func materialSwitchStateChanged(control: MaterialSwitch, state: MaterialSwitchState) {
print("MaterialSwitch - Size: \(control.switchSize) State: \(state)")
c2.switchState = state
}
}
......@@ -12,8 +12,8 @@
96A71FCB1C765FDF00C0C4AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A71FCA1C765FDF00C0C4AE /* Assets.xcassets */; };
96A71FCE1C765FDF00C0C4AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A71FCC1C765FDF00C0C4AE /* LaunchScreen.storyboard */; };
96A71FD61C76618D00C0C4AE /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71FD51C76618D00C0C4AE /* MainViewController.swift */; };
96A71FD81C7661D200C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71FD71C7661D200C0C4AE /* Material.framework */; };
96A71FD91C7661D200C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71FD71C7661D200C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96A7200C1C76E53A00C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A7200B1C76E53A00C0C4AE /* Material.framework */; };
96A7200D1C76E53A00C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A7200B1C76E53A00C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -23,7 +23,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96A71FD91C7661D200C0C4AE /* Material.framework in Embed Frameworks */,
96A7200D1C76E53A00C0C4AE /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -38,7 +38,7 @@
96A71FCD1C765FDF00C0C4AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96A71FCF1C765FDF00C0C4AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96A71FD51C76618D00C0C4AE /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
96A71FD71C7661D200C0C4AE /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
96A7200B1C76E53A00C0C4AE /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -46,7 +46,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96A71FD81C7661D200C0C4AE /* Material.framework in Frameworks */,
96A7200C1C76E53A00C0C4AE /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -56,7 +56,7 @@
96A71FB71C765FDF00C0C4AE = {
isa = PBXGroup;
children = (
96A71FD71C7661D200C0C4AE /* Material.framework */,
96A7200B1C76E53A00C0C4AE /* Material.framework */,
96A71FC21C765FDF00C0C4AE /* NavigationBarViewController */,
96A71FC11C765FDF00C0C4AE /* Products */,
);
......
......@@ -14,8 +14,7 @@
9642FA331C1B909700022BC6 /* LeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9642FA321C1B909700022BC6 /* LeftViewController.swift */; };
967585381C569AA9001E4268 /* RightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967585371C569AA9001E4268 /* RightViewController.swift */; };
96A71F471C74AD0700C0C4AE /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A71F461C74AD0700C0C4AE /* FeedViewController.swift */; };
96A71F8A1C76452300C0C4AE /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F891C76452300C0C4AE /* Material.framework */; };
96A71F8B1C76452300C0C4AE /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96A71F891C76452300C0C4AE /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96A7200A1C76E09100C0C4AE /* NoteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A720091C76E09100C0C4AE /* NoteViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -25,7 +24,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
96A71F8B1C76452300C0C4AE /* Material.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -42,7 +40,7 @@
9642FA321C1B909700022BC6 /* LeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftViewController.swift; sourceTree = "<group>"; };
967585371C569AA9001E4268 /* RightViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RightViewController.swift; sourceTree = "<group>"; };
96A71F461C74AD0700C0C4AE /* FeedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = "<group>"; };
96A71F891C76452300C0C4AE /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
96A720091C76E09100C0C4AE /* NoteViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoteViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -50,7 +48,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96A71F8A1C76452300C0C4AE /* Material.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -60,7 +57,6 @@
9642FA0E1C1B50E700022BC6 = {
isa = PBXGroup;
children = (
96A71F891C76452300C0C4AE /* Material.framework */,
9642FA191C1B50E700022BC6 /* SideNavigationViewController */,
9642FA181C1B50E700022BC6 /* Products */,
);
......@@ -82,6 +78,7 @@
9642FA321C1B909700022BC6 /* LeftViewController.swift */,
967585371C569AA9001E4268 /* RightViewController.swift */,
96A71F461C74AD0700C0C4AE /* FeedViewController.swift */,
96A720091C76E09100C0C4AE /* NoteViewController.swift */,
9642FA211C1B50E700022BC6 /* Assets.xcassets */,
9642FA231C1B50E700022BC6 /* LaunchScreen.storyboard */,
9642FA261C1B50E700022BC6 /* Info.plist */,
......@@ -164,6 +161,7 @@
967585381C569AA9001E4268 /* RightViewController.swift in Sources */,
96A71F471C74AD0700C0C4AE /* FeedViewController.swift in Sources */,
9642FA331C1B909700022BC6 /* LeftViewController.swift in Sources */,
96A7200A1C76E09100C0C4AE /* NoteViewController.swift in Sources */,
9642FA1B1C1B50E700022BC6 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
......@@ -113,6 +113,12 @@ class AppNavigationBarViewController: NavigationBarViewController {
first?.setImage(image, forState: .Highlighted)
}
func openNote() {
let x = 10
print(x)
navigationBarViewController?.transitionFromMainViewController(NoteViewController(), duration: 0.5, options: [], animations: nil, completion: nil)
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.white
......@@ -194,8 +200,10 @@ class AppNavigationBarViewController: NavigationBarViewController {
btn2.backgroundColor = MaterialColor.blue.base
btn2.setImage(image, forState: .Normal)
btn2.setImage(image, forState: .Highlighted)
btn2.addTarget(self, action: "openNote", forControlEvents: .TouchUpInside)
menuView.addSubview(btn2)
image = UIImage(named: "ic_photo_camera_white")
let btn3: FabButton = FabButton()
btn3.backgroundColor = MaterialColor.green.base
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of GraphKit nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
import Material
private struct Item {
var text: String
var detail: String
var image: UIImage?
}
class NoteViewController: UIViewController {
/// A tableView used to display Bond entries.
private let tableView: UITableView = UITableView()
/// A list of all the Author Bond types.
private var items: Array<Item> = Array<Item>()
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
prepareItems()
prepareTableView()
}
/**
Handles the search button click, which opens the
SideNavigationBarViewController.
*/
func handleSearchButton() {
sideNavigationBarViewController?.openRightView()
}
/// Prepares view.
private func prepareView() {
view.backgroundColor = MaterialColor.grey.darken4
}
/// Prepares the items Array.
private func prepareItems() {
items.append(Item(text: "Giants game", detail: "Are we on this weekend for the game?", image: UIImage(named: "Profile4")))
// items.append(Item(text: "Recipe to try", detail: "We should eat this: Squash, Corn and tomatillo Tacos.", image: UIImage(named: "Profile5")))
// items.append(Item(text: "Interview", detail: "The candidate will be arriving at 11:30, are you free?", image: UIImage(named: "Profile6")))
// items.append(Item(text: "Book recommendation", detail: "I found the book title, Surely You’re Joking, Mr. Feynman!", image: UIImage(named: "Profile7")))
// items.append(Item(text: "Oui oui", detail: "Do you have Paris recommendations? Have you ever been?", image: UIImage(named: "Profile8")))
}
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.dataSource = self
tableView.delegate = self
// Use MaterialLayout to easily align the tableView.
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: tableView)
}
}
/// TableViewDataSource methods.
extension NoteViewController: UITableViewDataSource {
/// Determines the number of rows in the tableView.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count;
}
/// Returns the number of sections.
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: MaterialTableViewCell = MaterialTableViewCell(style: .Subtitle, reuseIdentifier: "MaterialTableViewCell")
let item: Item = items[indexPath.row]
cell.selectionStyle = .None
cell.textLabel!.text = item.text
cell.textLabel!.font = RobotoFont.regular
cell.detailTextLabel!.text = item.detail
cell.detailTextLabel!.font = RobotoFont.regular
cell.detailTextLabel!.textColor = MaterialColor.grey.darken1
cell.imageView!.image = item.image?.resize(toWidth: 40)
cell.imageView!.layer.cornerRadius = 20
return cell
}
/// Prepares the header within the tableView.
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = UIView(frame: CGRectMake(0, 0, view.bounds.width, 48))
header.backgroundColor = MaterialColor.white
let label: UILabel = UILabel()
label.font = RobotoFont.medium
label.textColor = MaterialColor.grey.darken1
label.text = "Today"
header.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(header, child: label, left: navigationBarViewController!.navigationBarView.contentInset.left + navigationBarViewController!.navigationBarView.spacing)
return header
}
}
/// UITableViewDelegate methods.
extension NoteViewController: UITableViewDelegate {
/// Sets the tableView cell height.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 80
}
/// Sets the tableView header height.
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 48
}
}
......@@ -168,26 +168,7 @@ public class MaterialSwitch: UIControl {
/// MaterialSwitch state.
public var switchState: MaterialSwitchState = .Off {
didSet {
if oldValue != switchState {
userInteractionEnabled = false
UIView.animateWithDuration(0.15,
delay: 0.05,
options: .CurveEaseInOut,
animations: { [unowned self] in
self.button.x = .On == self.switchState ? self.onPosition + self.bounceOffset : self.offPosition - self.bounceOffset
self.styleForState(self.switchState)
}) { [unowned self] _ in
self.styleForState(self.switchState)
self.sendActionsForControlEvents(.ValueChanged)
self.delegate?.materialSwitchStateChanged(self, state: self.switchState)
UIView.animateWithDuration(0.15,
animations: { [unowned self] in
self.button.x = .On == self.switchState ? self.onPosition : self.offPosition
}) { [unowned self] _ in
self.userInteractionEnabled = true
}
}
}
setSwitchState(switchState, animated: true)
}
}
......@@ -313,7 +294,47 @@ public class MaterialSwitch: UIControl {
- Parameter completion: An Optional completion block.
*/
public func toggle(completion: ((control: MaterialSwitch) -> Void)? = nil) {
switchState = .On == switchState ? .Off : .On
setSwitchState(.On == switchState ? .Off : .On, animated: true, completion: completion)
}
/**
Set the switchState property with an option to animate.
- Parameter state: The MaterialSwitchState to set.
- Parameter animated: A Boolean indicating to set the animation or not.
- Parameter completion: An Optional completion block.
*/
public func setSwitchState(state: MaterialSwitchState, animated: Bool = true, completion: ((control: MaterialSwitch) -> Void)? = nil) {
if switchState != state {
if animated {
userInteractionEnabled = false
UIView.animateWithDuration(0.15,
delay: 0.05,
options: .CurveEaseInOut,
animations: { [unowned self] in
self.button.x = .On == state ? self.onPosition + self.bounceOffset : self.offPosition - self.bounceOffset
self.styleForState(state)
}) { [unowned self] _ in
self.styleForState(state)
self.sendActionsForControlEvents(.ValueChanged)
self.switchState = state
self.delegate?.materialSwitchStateChanged(self, state: state)
UIView.animateWithDuration(0.15,
animations: { [unowned self] in
self.button.x = .On == state ? self.onPosition : self.offPosition
}) { [unowned self] _ in
self.userInteractionEnabled = true
completion?(control: self)
}
}
} else {
button.x = .On == state ? self.onPosition : self.offPosition
styleForState(state)
sendActionsForControlEvents(.ValueChanged)
switchState = state
delegate?.materialSwitchStateChanged(self, state: state)
completion?(control: self)
}
}
}
/// Handles the TouchUpInside event.
......@@ -331,7 +352,7 @@ public class MaterialSwitch: UIControl {
let t: CGPoint = v.previousLocationInView(sender)
let p: CGPoint = v.locationInView(sender)
let q: CGFloat = sender.x + p.x - t.x
switchState = q > (width - button.width) / 2 ? .On : .Off
setSwitchState(q > (width - button.width) / 2 ? .On : .Off, animated: true)
}
}
......@@ -354,7 +375,7 @@ public class MaterialSwitch: UIControl {
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
if true == CGRectContainsPoint(trackLayer.frame, layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)) {
switchState = .On == switchState ? .Off : .On
setSwitchState(.On == switchState ? .Off : .On)
}
}
......@@ -379,7 +400,7 @@ public class MaterialSwitch: UIControl {
- Parameter state: The MaterialSwitchState to set.
*/
private func prepareSwitchState(state: MaterialSwitchState) {
switchState = state
setSwitchState(state, animated: false)
}
/**
......@@ -465,4 +486,4 @@ public class MaterialSwitch: UIControl {
button.x = onPosition
}
}
}
}
\ No newline at end of file
......@@ -103,7 +103,7 @@ public class NavigationBarViewController: UIViewController {
the transition animation from the active mainViewController
to the toViewController has completed.
*/
public func transitionFromMainViewController(toViewController: UIViewController, duration: NSTimeInterval, options: UIViewAnimationOptions, animations: (() -> Void)?, completion: ((Bool) -> Void)?) {
public func transitionFromMainViewController(toViewController: UIViewController, duration: NSTimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)?, completion: ((Bool) -> Void)?) {
mainViewController.willMoveToParentViewController(nil)
addChildViewController(toViewController)
toViewController.view.frame = view.bounds
......
......@@ -358,7 +358,7 @@ public class SideNavigationBarViewController: UIViewController, UIGestureRecogni
the transition animation from the active mainViewController
to the toViewController has completed.
*/
public func transitionFromMainViewController(toViewController: UIViewController, duration: NSTimeInterval, options: UIViewAnimationOptions, animations: (() -> Void)?, completion: ((Bool) -> Void)?) {
public func transitionFromMainViewController(toViewController: UIViewController, duration: NSTimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)?, completion: ((Bool) -> Void)?) {
mainViewController.willMoveToParentViewController(nil)
addChildViewController(toViewController)
toViewController.view.frame = view.bounds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment