{"id":7939,"date":"2015-11-12T03:04:07","date_gmt":"2015-11-12T03:04:07","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/12\/cocoatoucher-aiflatswitch\/"},"modified":"2015-11-12T03:04:07","modified_gmt":"2015-11-12T03:04:07","slug":"cocoatoucher-aiflatswitch","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/12\/cocoatoucher-aiflatswitch\/","title":{"rendered":"cocoatoucher\/AIFlatSwitch"},"content":{"rendered":"<p>A smooth, nice looking and IBDesignable animated flat switch component for iOS<\/p>\n<p>Inspired by Creativedash\u2019s Dribbble post here<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/s3.amazonaws.com\/f.cl.ly\/items\/1p0w3B0E3m2I2k3e0z1Q\/onoff.gif\" \/><\/p>\n<p>##Requirements<\/p>\n<h2>Installation<\/h2>\n<blockquote>\n<p><strong>Embedded frameworks require a minimum deployment target of iOS 8.<\/strong><\/p>\n<p>To use with a project targeting iOS 7, you must include the <code>AIFlatSwitch.swift<\/code> source file directly in your project.<\/p>\n<\/blockquote>\n<h3>CocoaPods<\/h3>\n<p>CocoaPods is a dependency manager for Cocoa projects.<\/p>\n<p>CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:<\/p>\n<pre><code>$ gem install cocoapods\n<\/code><\/pre>\n<p>To integrate AIFlatSwitch into your Xcode project using CocoaPods, specify it in your <code>Podfile<\/code>:<\/p>\n<pre><code>source 'https:\/\/github.com\/CocoaPods\/Specs.git'\nplatform :ios, '8.0'\nuse_frameworks!\n\npod 'AIFlatSwitch', '~&gt; 0.0.1'\n<\/code><\/pre>\n<p>Then, run the following command:<\/p>\n<pre><code>$ pod install\n<\/code><\/pre>\n<h2>Usage<\/h2>\n<h3>Creating the flat switch<\/h3>\n<pre><code>var flatSwitch = AIFlatSwitch(frame: CGRectMake(0, 0, 50, 50))\n<\/code><\/pre>\n<h3>Methods<\/h3>\n<blockquote>\n<p>To change its selected state:<\/p>\n<\/blockquote>\n<pre><code>flatSwitch.selected = true\n<\/code><\/pre>\n<blockquote>\n<p>or:<\/p>\n<\/blockquote>\n<pre><code>flatSwitch.setSelected(true, animated: true)\n<\/code><\/pre>\n<blockquote>\n<p>To listen to its state changes:<\/p>\n<\/blockquote>\n<pre><code>@IBAction func onSwitchValueChange(sender: AnyObject) {\n        if let flatSwitch = sender as? AIFlatSwitch {\n            println(flatSwitch.selected)\n        }\n    }\n<\/code><\/pre>\n<blockquote>\n<p>Styling the switch:<\/p>\n<\/blockquote>\n<pre><code>flatSwitch.lineWidth = 2.0\nflatSwitch.strokeColor = UIColor.blueColor()\nflatSwitch.trailStrokeColor = UIColor.redColor()\n<\/code><\/pre>\n<h2>License<\/h2>\n<p>AIFlatSwitch is released under the MIT license. See LICENSE for details.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A smooth, nice looking and IBDesignable animated flat switch component for iOS Inspired by Creativedash\u2019s Dribbble post here ##Requirements Installation Embedded frameworks require a minimum deployment target of iOS 8. To use with a project targeting iOS 7, you must include the AIFlatSwitch.swift source file directly in your project. CocoaPods CocoaPods is a dependency manager [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7939","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7939","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7939"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7939\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}