Repository: neopixl/NPFlipButton Branch: master Commit: 69a882188c8a Files: 17 Total size: 79.0 KB Directory structure: gitextract_arh7ggj0/ ├── .gitignore ├── LICENSE ├── NPButtonFlip/ │ ├── AppDelegate.swift │ ├── Base.lproj/ │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Classes/ │ │ ├── NPButtonWithFlip/ │ │ │ └── NPButtonWithFilp.swift │ │ └── NPFlipView/ │ │ └── NPFlipView.swift │ ├── Images.xcassets/ │ │ └── AppIcon.appiconset/ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift ├── NPButtonFlip.xcodeproj/ │ ├── project.pbxproj │ └── project.xcworkspace/ │ ├── contents.xcworkspacedata │ └── xcshareddata/ │ └── IDEWorkspaceChecks.plist ├── NPButtonFlipTests/ │ ├── Info.plist │ └── NPButtonFlipTests.swift ├── NPFlipButton.podspec └── README.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .DS_Store NPButtonFlip.xcodeproj/project.xcworkspace/xcuserdata/savepanda.xcuserdatad/UserInterfaceState.xcuserstate NPButtonFlip.xcodeproj/xcuserdata/* UserInterfaceState.xcuserstate NPButtonFlip.xccheckout ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: NPButtonFlip/AppDelegate.swift ================================================ // // AppDelegate.swift // NPButtonFlip // // Created by Glibert Axel on 30/12/14. // Copyright (c) 2014 Neopixl. All rights reserved. // import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. return true } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } } ================================================ FILE: NPButtonFlip/Base.lproj/LaunchScreen.xib ================================================ ================================================ FILE: NPButtonFlip/Base.lproj/Main.storyboard ================================================ ================================================ FILE: NPButtonFlip/Classes/NPButtonWithFlip/NPButtonWithFilp.swift ================================================ /* Copyright 2015 NEOPIXL S.A. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import UIKit public class NPButtonWithFilp: UIControl { var borderColor: UIColor! var offColor: UIColor! var onColor: UIColor! private var flipButton: NPFlipView! var flipOffImage: UIImage! var flipOnImage: UIImage! var text: String! var textFont: UIFont! private var currentOff = true private var label: UILabel! // MARK: - Init required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) initComponents() } override init(frame: CGRect) { super.init(frame: frame) initComponents() } // MARK: - Private methods private func initComponents() { self.label = UILabel() self.flipButton = NPFlipView(frame: CGRect(x: 0, y: 0, width: 32, height: 36)) label.translatesAutoresizingMaskIntoConstraints = false flipButton.translatesAutoresizingMaskIntoConstraints = false self.addSubview(label) self.addSubview(flipButton) let labelCenterYConstraint = NSLayoutConstraint(item:label, attribute:NSLayoutConstraint.Attribute.centerY, relatedBy:NSLayoutConstraint.Relation.equal, toItem:self, attribute:NSLayoutConstraint.Attribute.centerY, multiplier:1, constant:0) self.addConstraint(labelCenterYConstraint) let labelPinLeftBorderConstraint = NSLayoutConstraint(item:label, attribute:NSLayoutConstraint.Attribute.leading, relatedBy:NSLayoutConstraint.Relation.equal, toItem:self, attribute:NSLayoutConstraint.Attribute.leading, multiplier:1, constant:15) self.addConstraint(labelPinLeftBorderConstraint) let flipCenterYConstraint = NSLayoutConstraint(item:flipButton, attribute:NSLayoutConstraint.Attribute.centerY, relatedBy:NSLayoutConstraint.Relation.equal, toItem:self, attribute:NSLayoutConstraint.Attribute.centerY, multiplier:1, constant:2) self.addConstraint(flipCenterYConstraint) let flipPinLeftBorderConstraint = NSLayoutConstraint(item:flipButton, attribute:NSLayoutConstraint.Attribute.trailing, relatedBy:NSLayoutConstraint.Relation.equal, toItem:self, attribute:NSLayoutConstraint.Attribute.trailing, multiplier:1, constant:-10) self.addConstraint(flipPinLeftBorderConstraint) } // MARK: - Public methods public func setParameters(borderColor: UIColor, offColor: UIColor, onColor: UIColor, flipOffImage: UIImage, flipOnImage: UIImage, text: String, textFont: UIFont) { self.borderColor = borderColor self.offColor = offColor self.onColor = onColor self.flipOffImage = flipOffImage self.flipOnImage = flipOnImage self.text = text label.text = self.text self.textFont = textFont label.font = self.textFont label.textColor = self.onColor self.layer.borderColor = self.borderColor.cgColor self.layer.borderWidth = 1 self.layer.cornerRadius = 2 self.backgroundColor = offColor flipButton.setImages(frontImage: flipOnImage, backImage: flipOffImage) flipButton.addTarget(self, action: #selector(flipTouchDown), for: .touchDown) flipButton.addTarget(self, action: #selector(flipTouchUpInside), for: .touchUpInside) flipButton.removeConstraints(flipButton.constraints) let views = ["view": flipButton] //+4 for shadow let verticalConstraints = NSLayoutConstraint.constraints(withVisualFormat:"V:[view(\(flipOffImage.size.height+4))]", options: [], metrics: nil, views: views as [String : Any]) flipButton.addConstraints(verticalConstraints) let horizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:[view(\(flipOffImage.size.width))]", options: [], metrics: nil, views: views as [String : Any]) flipButton.addConstraints(horizontalConstraints) } public func setState (on: Bool, animated: Bool) { if(currentOff == on) { if !on { if animated { UIView.animate(withDuration: 0.2, animations: { self.backgroundColor = self.offColor self.label.textColor = self.onColor }) } else { self.backgroundColor = self.offColor self.label.textColor = self.onColor } } else { if animated { UIView.animate(withDuration: 0.2, animations: { self.backgroundColor = self.onColor self.label.textColor = self.offColor }) } else { self.backgroundColor = self.onColor self.label.textColor = self.offColor } } self.flipButton.flip(animated: animated, duration: 0.3, toBack: on, completionBlock: nil) self.currentOff = !on } } public override func touchesBegan(_ touches: Set, with event: UIEvent?) { didBegin() } private func didBegin() { if self.currentOff { UIView.animate(withDuration: 0.2, animations: { self.backgroundColor = self.onColor self.label.textColor = self.offColor }) } else { UIView.animate(withDuration: 0.2, animations: { self.backgroundColor = self.offColor self.label.textColor = self.onColor }) } self.currentOff = !self.currentOff self.sendActions(for: .touchDown) } public override func touchesEnded(_ touches: Set, with event: UIEvent?) { didEnd() } private func didEnd() { self.flipButton.flip(animated: true, duration: 0.3, completionBlock: nil) self.sendActions(for: .touchUpInside) } @objc internal func flipTouchUpInside() { didEnd() } @objc internal func flipTouchDown() { didBegin() } } ================================================ FILE: NPButtonFlip/Classes/NPFlipView/NPFlipView.swift ================================================ /* Copyright 2015 NEOPIXL S.A. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import UIKit public class NPFlipView: UIControl { private var frontImageView=UIImageView() private var backImageView=UIImageView() private var backDisplayed = false private var completionBlock:(() -> Void)? // MARK: - init override init(frame: CGRect) { super.init(frame: frame) self.addSubview(frontImageView) self.addSubview(backImageView) } required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.addSubview(frontImageView) self.addSubview(backImageView) } // MARK: - set front and back Images public func setImages(frontImage: UIImage, backImage: UIImage) { self.frontImageView.image = frontImage self.frontImageView.frame.size = frontImage.size self.backImageView.image = backImage self.backImageView.frame.size = backImage.size self.enableSadow() } // MARK: - Disable Shadow on Image public func disableShadow() { self.frontImageView.layer.shadowColor = nil self.frontImageView.layer.shadowOpacity = 1 self.frontImageView.layer.shadowOffset = CGSize() self.frontImageView.layer.shadowRadius = 0 self.frontImageView.layer.masksToBounds = false self.frontImageView.layer.zPosition = 0 self.frontImageView.layer.shouldRasterize = true self.backImageView.layer.shadowColor = nil self.backImageView.layer.shadowOpacity = 1 self.backImageView.layer.shadowOffset = CGSize() self.backImageView.layer.shadowRadius = 0 self.backImageView.layer.masksToBounds = false self.backImageView.layer.zPosition = 0 self.backImageView.layer.shouldRasterize = true } // MARK: - Enable Shadow on Image public func enableSadow() { self.frontImageView.layer.shadowColor = UIColor.black.cgColor self.frontImageView.layer.shadowOpacity = 0.25 self.frontImageView.layer.shadowOffset = CGSize(width: 0, height: 2) self.frontImageView.layer.shadowRadius = 2 self.frontImageView.layer.masksToBounds = false self.frontImageView.layer.zPosition = -1 self.frontImageView.layer.shouldRasterize = true self.backImageView.layer.shadowColor = UIColor.black.cgColor self.backImageView.layer.shadowOpacity = 0.25 self.backImageView.layer.shadowOffset = CGSize(width: 0, height: 2) self.backImageView.layer.shadowRadius = 2 self.backImageView.layer.masksToBounds = false self.backImageView.layer.zPosition = -1 self.backImageView.layer.shouldRasterize = true } // MARK: - touches Management public override func touchesBegan(_ touches: Set, with event: UIEvent?) { self.sendActions(for: .touchDown) } public override func touchesEnded(_ touches: Set, with event: UIEvent?) { self.sendActions(for: .touchUpInside) } // MARK: - flip public func flip(animated: Bool, duration: TimeInterval, completionBlock:(() -> Void)!) { if animated { UIView.transition(with: self, duration: 0.3, options: .transitionFlipFromRight, animations: { //animations if !self.backDisplayed { self.backImageView.removeFromSuperview() self.addSubview(self.frontImageView) } else { self.frontImageView.removeFromSuperview() self.addSubview(self.backImageView) } self.backDisplayed = !self.backDisplayed }, completion: { (finished) in if let block = completionBlock { block() } }) } else { if !self.backDisplayed { self.backImageView.removeFromSuperview() self.addSubview(self.frontImageView) } else { self.frontImageView.removeFromSuperview() self.addSubview(self.backImageView) } if let block = completionBlock { block() } } } public func flip(animated: Bool, duration: TimeInterval, toBack: Bool, completionBlock: ((Bool) -> Void)!) { if(toBack != backDisplayed) { if animated { UIView.transition(with: self, duration: 0.3, options: .transitionFlipFromRight, animations: { //animations if toBack { self.backImageView.removeFromSuperview() self.addSubview(self.frontImageView) } else { self.frontImageView.removeFromSuperview() self.addSubview(self.backImageView) } self.backDisplayed = toBack }, completion: { (finished) in if let block = completionBlock { block(finished) } }) } else { if toBack { self.backImageView.removeFromSuperview() self.addSubview(self.frontImageView) } else { self.frontImageView.removeFromSuperview() self.addSubview(self.backImageView) } self.backDisplayed = toBack if let block = completionBlock { block(true) } } } } } ================================================ FILE: NPButtonFlip/Images.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "3x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "3x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "2x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: NPButtonFlip/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1 LSRequiresIPhoneOS UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight ================================================ FILE: NPButtonFlip/ViewController.swift ================================================ // // ViewController.swift // NPButtonFlip // // Created by Glibert Axel on 30/12/14. // Copyright (c) 2014 Neopixl. All rights reserved. // import UIKit class ViewController: UIViewController { @IBOutlet weak var buttonBig: NPButtonWithFilp! @IBOutlet weak var buttonLeft: NPButtonWithFilp! @IBOutlet weak var buttonRight: NPButtonWithFilp! @IBOutlet weak var labelAction: UILabel! @IBOutlet weak var flipLeft: NPFlipView! @IBOutlet weak var flipRight: NPFlipView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. if let textFont = UIFont(name: "HelveticaNeue-Light", size: 16) { if let imageOff = UIImage(named: "btn_right_off") { if let imageOn = UIImage(named: "btn_right_on") { let borderColor = UIColor(white: 230/255, alpha: 1) let offColor = UIColor.white let onColor = UIColor(red: 93/255, green: 202/255, blue: 115/255, alpha: 1) buttonBig.setParameters(borderColor: borderColor, offColor: offColor, onColor: onColor, flipOffImage: imageOff, flipOnImage: imageOn, text: "This is good", textFont: textFont) buttonRight.setParameters(borderColor: borderColor, offColor: offColor, onColor: onColor, flipOffImage: imageOff, flipOnImage: imageOn, text: "Good", textFont: textFont) //Frame of the NPFlipView must be a little bigger than the image to not crop the shadow animation if shadow is used (by default it's used) flipRight.setImages(frontImage: imageOff, backImage: imageOn) } } if let imageOff = UIImage(named: "btn_wrong_off") { if let imageOn = UIImage(named: "btn_wrong_on") { let borderColor = UIColor(white: 230/255, alpha: 1) let offColor = UIColor.white let onColor = UIColor(red: 222/255, green: 142/255, blue: 92/255, alpha: 1) buttonLeft.setParameters(borderColor: borderColor, offColor: offColor, onColor: onColor, flipOffImage: imageOff, flipOnImage: imageOn, text: "Bad", textFont: textFont) //Frame of the NPFlipView must be a little bigger than the image to not crop the shadow animation if shadow is used (by default it's used) flipLeft.setImages(frontImage: imageOff, backImage: imageOn) flipLeft.disableShadow() } } } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } // MARK: Buttons Actions @IBAction func buttonBigTouchUpInside(_ sender: Any) { labelAction.text = "Action : This is good TouchUpInside" } @IBAction func buttonBigTouchDown(_ sender: Any) { labelAction.text = "Action : This is good TouchDown" } @IBAction func buttonLeftTouchUpInside(_ sender: Any) { labelAction.text = "Action : Bad TouchUpInside" } @IBAction func buttonLeftTouchDown(_ sender: Any) { labelAction.text = "Action : Bad TouchDown" } @IBAction func buttonRightTouchUpInside(_ sender: Any) { labelAction.text = "Action : Good TouchUpInside" } @IBAction func buttonRightTouchDown(_ sender: Any) { labelAction.text = "Action : Good TouchDown" } @IBAction func flipViewLeftTouchUpInside(_ sender: Any) { labelAction.text = "Action : flipLeft TouchUpInside" //flip the flipLeft and when finished, display a alert. flipLeft.flip(animated: true, duration: 0.3, completionBlock: { () -> Void in let refreshAlert = UIAlertView() refreshAlert.title = "Finished" refreshAlert.message = "Flip finished." refreshAlert.addButton(withTitle: "OK") refreshAlert.show() }) } @IBAction func flipViewLeftTouchDown(_ sender: Any) { labelAction.text = "Action : flipLeft TouchDown" } @IBAction func flipViewRightTouchUpInside(_ sender: Any) { labelAction.text = "Action : flipRight TouchUpInside" //flip the flipRight and when finished, display a alert. flipRight.flip(animated: true, duration: 0.3, completionBlock: { () -> Void in let refreshAlert = UIAlertView() refreshAlert.title = "Finished" refreshAlert.message = "Flip finished." refreshAlert.addButton(withTitle: "OK") refreshAlert.show() }) } @IBAction func flipViewRightTouchDown(_ sender: Any) { labelAction.text = "Action : flipRight TouchDown" } @IBAction func toBack(_ sender: Any) { //flip all flip to back flipRight.flip(animated: true, duration: 0.3, toBack:true, completionBlock: nil) flipLeft.flip(animated: true, duration: 0.3, toBack:true, completionBlock: nil) } @IBAction func toFront(_ sender: Any) { //flip all flip to front flipRight.flip(animated: true, duration: 0.3, toBack:false, completionBlock: nil) flipLeft.flip(animated: true, duration: 0.3, toBack:false, completionBlock: nil) } @IBAction func on(_ sender: Any) { //set all button to on buttonRight.setState(on: true, animated: true) buttonLeft.setState(on: true, animated: true) buttonBig.setState(on: true, animated: true) } @IBAction func off(_ sender: Any) { //set all button to off buttonRight.setState(on: false, animated: true) buttonLeft.setState(on: false, animated: true) buttonBig.setState(on: false, animated: true) } } ================================================ FILE: NPButtonFlip.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 77405D951A528E7700033517 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77405D941A528E7700033517 /* AppDelegate.swift */; }; 77405D971A528E7700033517 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77405D961A528E7700033517 /* ViewController.swift */; }; 77405D9A1A528E7700033517 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 77405D981A528E7700033517 /* Main.storyboard */; }; 77405D9C1A528E7700033517 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 77405D9B1A528E7700033517 /* Images.xcassets */; }; 77405D9F1A528E7700033517 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77405D9D1A528E7700033517 /* LaunchScreen.xib */; }; 77405DAB1A528E7700033517 /* NPButtonFlipTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77405DAA1A528E7700033517 /* NPButtonFlipTests.swift */; }; 77405DB91A528F4900033517 /* NPButtonWithFilp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77405DB61A528F4900033517 /* NPButtonWithFilp.swift */; }; 77405DBA1A528F4900033517 /* NPFlipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77405DB81A528F4900033517 /* NPFlipView.swift */; }; 77405DC41A52905400033517 /* btn_right_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 77405DBC1A52905400033517 /* btn_right_on.png */; }; 77405DC51A52905400033517 /* btn_right_on@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77405DBD1A52905400033517 /* btn_right_on@2x.png */; }; 77405DC61A52905400033517 /* btn_right_off.png in Resources */ = {isa = PBXBuildFile; fileRef = 77405DBE1A52905400033517 /* btn_right_off.png */; }; 77405DC71A52905400033517 /* btn_right_off@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77405DBF1A52905400033517 /* btn_right_off@2x.png */; }; 77405DC81A52905400033517 /* btn_wrong_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 77405DC01A52905400033517 /* btn_wrong_on.png */; }; 77405DC91A52905400033517 /* btn_wrong_on@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77405DC11A52905400033517 /* btn_wrong_on@2x.png */; }; 77405DCA1A52905400033517 /* btn_wrong_off.png in Resources */ = {isa = PBXBuildFile; fileRef = 77405DC21A52905400033517 /* btn_wrong_off.png */; }; 77405DCB1A52905400033517 /* btn_wrong_off@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77405DC31A52905400033517 /* btn_wrong_off@2x.png */; }; 779301221A5300C8003CE683 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 779301211A5300C8003CE683 /* README.md */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 77405DA51A528E7700033517 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 77405D871A528E7700033517 /* Project object */; proxyType = 1; remoteGlobalIDString = 77405D8E1A528E7700033517; remoteInfo = NPButtonFlip; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 77405D8F1A528E7700033517 /* NPButtonFlip.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NPButtonFlip.app; sourceTree = BUILT_PRODUCTS_DIR; }; 77405D931A528E7700033517 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 77405D941A528E7700033517 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 77405D961A528E7700033517 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 77405D991A528E7700033517 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 77405D9B1A528E7700033517 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 77405D9E1A528E7700033517 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 77405DA41A528E7700033517 /* NPButtonFlipTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NPButtonFlipTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 77405DA91A528E7700033517 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 77405DAA1A528E7700033517 /* NPButtonFlipTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NPButtonFlipTests.swift; sourceTree = ""; }; 77405DB61A528F4900033517 /* NPButtonWithFilp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NPButtonWithFilp.swift; sourceTree = ""; }; 77405DB81A528F4900033517 /* NPFlipView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NPFlipView.swift; sourceTree = ""; }; 77405DBC1A52905400033517 /* btn_right_on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = btn_right_on.png; sourceTree = ""; }; 77405DBD1A52905400033517 /* btn_right_on@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "btn_right_on@2x.png"; sourceTree = ""; }; 77405DBE1A52905400033517 /* btn_right_off.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = btn_right_off.png; sourceTree = ""; }; 77405DBF1A52905400033517 /* btn_right_off@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "btn_right_off@2x.png"; sourceTree = ""; }; 77405DC01A52905400033517 /* btn_wrong_on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = btn_wrong_on.png; sourceTree = ""; }; 77405DC11A52905400033517 /* btn_wrong_on@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "btn_wrong_on@2x.png"; sourceTree = ""; }; 77405DC21A52905400033517 /* btn_wrong_off.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = btn_wrong_off.png; sourceTree = ""; }; 77405DC31A52905400033517 /* btn_wrong_off@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "btn_wrong_off@2x.png"; sourceTree = ""; }; 779301211A5300C8003CE683 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 77405D8C1A528E7700033517 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 77405DA11A528E7700033517 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 77405D861A528E7700033517 = { isa = PBXGroup; children = ( 77405D911A528E7700033517 /* NPButtonFlip */, 77405DA71A528E7700033517 /* NPButtonFlipTests */, 77405D901A528E7700033517 /* Products */, 779301211A5300C8003CE683 /* README.md */, ); sourceTree = ""; }; 77405D901A528E7700033517 /* Products */ = { isa = PBXGroup; children = ( 77405D8F1A528E7700033517 /* NPButtonFlip.app */, 77405DA41A528E7700033517 /* NPButtonFlipTests.xctest */, ); name = Products; sourceTree = ""; }; 77405D911A528E7700033517 /* NPButtonFlip */ = { isa = PBXGroup; children = ( 77405DBB1A52905400033517 /* Ressources */, 77405DB41A528F4900033517 /* Classes */, 77405D941A528E7700033517 /* AppDelegate.swift */, 77405D961A528E7700033517 /* ViewController.swift */, 77405D981A528E7700033517 /* Main.storyboard */, 77405D9B1A528E7700033517 /* Images.xcassets */, 77405D9D1A528E7700033517 /* LaunchScreen.xib */, 77405D921A528E7700033517 /* Supporting Files */, ); path = NPButtonFlip; sourceTree = ""; }; 77405D921A528E7700033517 /* Supporting Files */ = { isa = PBXGroup; children = ( 77405D931A528E7700033517 /* Info.plist */, ); name = "Supporting Files"; sourceTree = ""; }; 77405DA71A528E7700033517 /* NPButtonFlipTests */ = { isa = PBXGroup; children = ( 77405DAA1A528E7700033517 /* NPButtonFlipTests.swift */, 77405DA81A528E7700033517 /* Supporting Files */, ); path = NPButtonFlipTests; sourceTree = ""; }; 77405DA81A528E7700033517 /* Supporting Files */ = { isa = PBXGroup; children = ( 77405DA91A528E7700033517 /* Info.plist */, ); name = "Supporting Files"; sourceTree = ""; }; 77405DB41A528F4900033517 /* Classes */ = { isa = PBXGroup; children = ( 77405DB51A528F4900033517 /* NPButtonWithFlip */, 77405DB71A528F4900033517 /* NPFlipView */, ); path = Classes; sourceTree = ""; }; 77405DB51A528F4900033517 /* NPButtonWithFlip */ = { isa = PBXGroup; children = ( 77405DB61A528F4900033517 /* NPButtonWithFilp.swift */, ); path = NPButtonWithFlip; sourceTree = ""; }; 77405DB71A528F4900033517 /* NPFlipView */ = { isa = PBXGroup; children = ( 77405DB81A528F4900033517 /* NPFlipView.swift */, ); path = NPFlipView; sourceTree = ""; }; 77405DBB1A52905400033517 /* Ressources */ = { isa = PBXGroup; children = ( 77405DBC1A52905400033517 /* btn_right_on.png */, 77405DBD1A52905400033517 /* btn_right_on@2x.png */, 77405DBE1A52905400033517 /* btn_right_off.png */, 77405DBF1A52905400033517 /* btn_right_off@2x.png */, 77405DC01A52905400033517 /* btn_wrong_on.png */, 77405DC11A52905400033517 /* btn_wrong_on@2x.png */, 77405DC21A52905400033517 /* btn_wrong_off.png */, 77405DC31A52905400033517 /* btn_wrong_off@2x.png */, ); path = Ressources; sourceTree = SOURCE_ROOT; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ 77405D8E1A528E7700033517 /* NPButtonFlip */ = { isa = PBXNativeTarget; buildConfigurationList = 77405DAE1A528E7700033517 /* Build configuration list for PBXNativeTarget "NPButtonFlip" */; buildPhases = ( 77405D8B1A528E7700033517 /* Sources */, 77405D8C1A528E7700033517 /* Frameworks */, 77405D8D1A528E7700033517 /* Resources */, ); buildRules = ( ); dependencies = ( ); name = NPButtonFlip; productName = NPButtonFlip; productReference = 77405D8F1A528E7700033517 /* NPButtonFlip.app */; productType = "com.apple.product-type.application"; }; 77405DA31A528E7700033517 /* NPButtonFlipTests */ = { isa = PBXNativeTarget; buildConfigurationList = 77405DB11A528E7700033517 /* Build configuration list for PBXNativeTarget "NPButtonFlipTests" */; buildPhases = ( 77405DA01A528E7700033517 /* Sources */, 77405DA11A528E7700033517 /* Frameworks */, 77405DA21A528E7700033517 /* Resources */, ); buildRules = ( ); dependencies = ( 77405DA61A528E7700033517 /* PBXTargetDependency */, ); name = NPButtonFlipTests; productName = NPButtonFlipTests; productReference = 77405DA41A528E7700033517 /* NPButtonFlipTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 77405D871A528E7700033517 /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 1010; ORGANIZATIONNAME = Neopixl; TargetAttributes = { 77405D8E1A528E7700033517 = { CreatedOnToolsVersion = 6.1.1; LastSwiftMigration = 0820; }; 77405DA31A528E7700033517 = { CreatedOnToolsVersion = 6.1.1; LastSwiftMigration = 0820; TestTargetID = 77405D8E1A528E7700033517; }; }; }; buildConfigurationList = 77405D8A1A528E7700033517 /* Build configuration list for PBXProject "NPButtonFlip" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); mainGroup = 77405D861A528E7700033517; productRefGroup = 77405D901A528E7700033517 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 77405D8E1A528E7700033517 /* NPButtonFlip */, 77405DA31A528E7700033517 /* NPButtonFlipTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 77405D8D1A528E7700033517 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 77405DC61A52905400033517 /* btn_right_off.png in Resources */, 77405DC71A52905400033517 /* btn_right_off@2x.png in Resources */, 77405D9A1A528E7700033517 /* Main.storyboard in Resources */, 77405D9F1A528E7700033517 /* LaunchScreen.xib in Resources */, 77405D9C1A528E7700033517 /* Images.xcassets in Resources */, 77405DC51A52905400033517 /* btn_right_on@2x.png in Resources */, 77405DC81A52905400033517 /* btn_wrong_on.png in Resources */, 77405DCA1A52905400033517 /* btn_wrong_off.png in Resources */, 77405DCB1A52905400033517 /* btn_wrong_off@2x.png in Resources */, 77405DC41A52905400033517 /* btn_right_on.png in Resources */, 77405DC91A52905400033517 /* btn_wrong_on@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 77405DA21A528E7700033517 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 77405D8B1A528E7700033517 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 77405DB91A528F4900033517 /* NPButtonWithFilp.swift in Sources */, 77405D971A528E7700033517 /* ViewController.swift in Sources */, 779301221A5300C8003CE683 /* README.md in Sources */, 77405D951A528E7700033517 /* AppDelegate.swift in Sources */, 77405DBA1A528F4900033517 /* NPFlipView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 77405DA01A528E7700033517 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 77405DAB1A528E7700033517 /* NPButtonFlipTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 77405DA61A528E7700033517 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 77405D8E1A528E7700033517 /* NPButtonFlip */; targetProxy = 77405DA51A528E7700033517 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 77405D981A528E7700033517 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( 77405D991A528E7700033517 /* Base */, ); name = Main.storyboard; sourceTree = ""; }; 77405D9D1A528E7700033517 /* LaunchScreen.xib */ = { isa = PBXVariantGroup; children = ( 77405D9E1A528E7700033517 /* Base */, ); name = LaunchScreen.xib; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 77405DAC1A528E7700033517 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; 77405DAD1A528E7700033517 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; }; 77405DAF1A528E7700033517 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = NPButtonFlip/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.neopixl.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; }; name = Debug; }; 77405DB01A528E7700033517 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = NPButtonFlip/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.neopixl.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; }; name = Release; }; 77405DB21A528E7700033517 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); INFOPLIST_FILE = NPButtonFlipTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.neopixl.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NPButtonFlip.app/NPButtonFlip"; }; name = Debug; }; 77405DB31A528E7700033517 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", ); INFOPLIST_FILE = NPButtonFlipTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.neopixl.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NPButtonFlip.app/NPButtonFlip"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 77405D8A1A528E7700033517 /* Build configuration list for PBXProject "NPButtonFlip" */ = { isa = XCConfigurationList; buildConfigurations = ( 77405DAC1A528E7700033517 /* Debug */, 77405DAD1A528E7700033517 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 77405DAE1A528E7700033517 /* Build configuration list for PBXNativeTarget "NPButtonFlip" */ = { isa = XCConfigurationList; buildConfigurations = ( 77405DAF1A528E7700033517 /* Debug */, 77405DB01A528E7700033517 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 77405DB11A528E7700033517 /* Build configuration list for PBXNativeTarget "NPButtonFlipTests" */ = { isa = XCConfigurationList; buildConfigurations = ( 77405DB21A528E7700033517 /* Debug */, 77405DB31A528E7700033517 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 77405D871A528E7700033517 /* Project object */; } ================================================ FILE: NPButtonFlip.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: NPButtonFlip.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist ================================================ IDEDidComputeMac32BitWarning ================================================ FILE: NPButtonFlipTests/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType BNDL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1 ================================================ FILE: NPButtonFlipTests/NPButtonFlipTests.swift ================================================ // // NPButtonFlipTests.swift // NPButtonFlipTests // // Created by Glibert Axel on 30/12/14. // Copyright (c) 2014 Neopixl. All rights reserved. // import UIKit import XCTest class NPButtonFlipTests: XCTestCase { override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. } override func tearDown() { // Put teardown code here. This method is called after the invocation of each test method in the class. super.tearDown() } func testExample() { // This is an example of a functional test case. XCTAssert(true, "Pass") } func testPerformanceExample() { // This is an example of a performance test case. self.measure() { // Put the code you want to measure the time of here. } } } ================================================ FILE: NPFlipButton.podspec ================================================ Pod::Spec.new do |s| s.name = 'NPFlipButton' s.version = '1.0.2' s.license = 'Apache 2.0' s.summary = 'This is a simple button with a circle at right, who will animate when changing state.' s.homepage = 'https://github.com/neopixl/NPFlipButton' s.social_media_url = 'http://twitter.com/neopixl' s.authors = { 'Neopixl S.A.' => 'contact@neopixl.com' } s.source = { :git => 'https://github.com/neopixl/NPFlipButton.git', :tag => s.version } s.platform = :ios s.ios.deployment_target = '8.0' s.source_files = 'NPButtonFlip/Classes/*/*.swift' s.requires_arc = true end ================================================ FILE: README.md ================================================ # NPFlipButton ![Version](https://img.shields.io/cocoapods/v/NPFlipButton.svg?style=flat) ![License](https://img.shields.io/cocoapods/l/NPFlipButton.svg?style=flat) ![Platform](https://img.shields.io/cocoapods/p/NPFlipButton.svg?style=flat) *** This is a simple button with a circle at right, who will animate when changing state. ## Features - automatically draw the button and set its text - animate the state change ## Installation > **Embedded frameworks require a minimum deployment target of iOS 8.** > > To use NPFlipButton with a project targeting iOS 7, you must include the files in `Classes/NPButtonWithFlip` and `Classes/NPFlipView` directly in your project. > ### CocoaPods [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command: ```bash $ gem install cocoapods ``` To integrate NPFlipButton into your Xcode project using CocoaPods, specify it in your `Podfile`: ```ruby source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks! pod 'NPFlipButton' ``` ***Swift 2 Support*** (only with version 1.0.0) : ```ruby pod 'NPFlipButton', '~> 1.0.0' ``` Then, run the following command: ```bash $ pod install ``` ## Usage Import NPFlipButton ```swift import NPFlipButton ``` Instantiate a new NPButtonWithFlip or get it from a Storyboard Configure the parameters: ```swift button.setParameters(borderColor: borderColor, offColor: offColor, onColor: onColor, flipOffImage: imageOff, flipOnImage: imageOn, text: "Button", textFont: textFont) ``` ## Small Print ### Author [Neopixl](http://www.neopixl.com) ### License ------------------------- Copyright 2015 Neopixl S.A. - Apache 2.0 licence.