├── .gitignore ├── .swift-version ├── Classes └── FloatingView.swift ├── FloatingButton.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── FloatingButton ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── FloatingButtonTests ├── FloatingButtonTests.swift └── Info.plist ├── FloatingButtonUITests ├── FloatingButtonUITests.swift └── Info.plist ├── FloatingView.podspec ├── LICENSE ├── README.md └── Screenshot └── screen.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /Classes/FloatingView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FloatingView.swift 3 | // FloatingView 4 | // 5 | // Created by Ali Pourhadi on 2017-05-07. 6 | // Copyright © 2017 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public protocol FloatingViewDelegate { 13 | func viewDraggingDidBegin(view:UIView, in window:UIWindow?) 14 | func viewDraggingDidEnd(view:UIView, in window:UIWindow?) 15 | } 16 | 17 | class FloatingWindow : UIWindow { 18 | public var topView : UIView = UIView() 19 | lazy var pointInsideCalled : Bool = true 20 | 21 | override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { 22 | if self.point(inside: point, with: event) { 23 | self.pointInsideCalled = true 24 | return topView 25 | } 26 | if pointInsideCalled { 27 | self.pointInsideCalled = false 28 | return topView 29 | } 30 | return nil 31 | } 32 | } 33 | 34 | public class FloatingView { 35 | 36 | private var floatingWindow:FloatingWindow? 37 | private var appWindow:UIWindow? 38 | private var floatingView:UIView! 39 | 40 | /** 41 | is floating view showing 42 | */ 43 | public var isShowing = false 44 | 45 | /** 46 | Delegate reutrn events of your floating view. 47 | */ 48 | public var delegate:FloatingViewDelegate? 49 | 50 | /** 51 | Initilization of FloatingView 52 | 53 | - Parameter view: A normal view that turns to floating view. 54 | - Parameter layer: The layer of Z that the View will be presented, by default it is 1. in case of have more windows change it. 55 | 56 | */ 57 | public init(with view:UIView , layer:CGFloat = 1) { 58 | 59 | self.floatingView = view 60 | self.appWindow = UIApplication.shared.keyWindow 61 | self.floatingWindow = FloatingWindow(frame: view.frame) 62 | self.floatingWindow?.topView = view 63 | self.floatingWindow?.rootViewController?.view = view 64 | self.floatingWindow?.windowLevel = layer 65 | self.floatingWindow?.makeKeyAndVisible() 66 | 67 | let panGesture = UIPanGestureRecognizer(target: self, action:#selector(handlePanGesture(panGesture:))) 68 | panGesture.cancelsTouchesInView = false 69 | view.addGestureRecognizer(panGesture) 70 | 71 | } 72 | 73 | /** 74 | Showing floating view 75 | */ 76 | public func show() { 77 | if self.isShowing { return } 78 | self.floatingWindow?.addSubview(self.floatingView) 79 | self.isShowing = true 80 | floatingWindow?.isHidden = false 81 | } 82 | 83 | /** 84 | Hidding floating view 85 | */ 86 | public func hide() { 87 | self.isShowing = false 88 | floatingWindow?.isHidden = true 89 | } 90 | 91 | @objc private func handlePanGesture(panGesture: UIPanGestureRecognizer) { 92 | if panGesture.state == .began { 93 | self.delegate?.viewDraggingDidBegin(view: self.floatingView, in: self.floatingWindow) 94 | } 95 | 96 | if panGesture.state == .ended { 97 | self.delegate?.viewDraggingDidEnd(view: self.floatingView, in: self.floatingWindow) 98 | } 99 | 100 | if panGesture.state == .changed { 101 | let translation = panGesture.location(in: self.floatingView) 102 | self.viewDidMove(to: translation) 103 | } 104 | } 105 | 106 | // Handleing movement of view 107 | private func viewDidMove(to location:CGPoint) { 108 | UIView.animate(withDuration: 0.1, delay: 0.0, options: [.beginFromCurrentState,.curveEaseInOut], animations: { 109 | let point = (self.floatingWindow?.convert(location, to: self.appWindow))! 110 | switch UIDevice.current.orientation { 111 | case .portrait : 112 | self.floatingWindow?.center = point 113 | case .landscapeLeft : 114 | self.floatingWindow?.center = CGPoint(x: (self.appWindow?.frame.size.height)! - point.y, y: point.x) 115 | 116 | case .landscapeRight : 117 | self.floatingWindow?.center = CGPoint(x: point.y, y: (self.appWindow?.frame.size.width)! - point.x) 118 | default : 119 | print("Floating View Does not Handler This Situation") 120 | } 121 | }) 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /FloatingButton.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 32C988091EBFDECC004028A6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C988081EBFDECC004028A6 /* AppDelegate.swift */; }; 11 | 32C9880B1EBFDECD004028A6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C9880A1EBFDECD004028A6 /* ViewController.swift */; }; 12 | 32C9880E1EBFDECD004028A6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32C9880C1EBFDECD004028A6 /* Main.storyboard */; }; 13 | 32C988101EBFDECD004028A6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32C9880F1EBFDECD004028A6 /* Assets.xcassets */; }; 14 | 32C988131EBFDECE004028A6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32C988111EBFDECE004028A6 /* LaunchScreen.storyboard */; }; 15 | 32C9881E1EBFDED6004028A6 /* FloatingButtonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C9881D1EBFDED6004028A6 /* FloatingButtonTests.swift */; }; 16 | 32C988291EBFDED7004028A6 /* FloatingButtonUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C988281EBFDED7004028A6 /* FloatingButtonUITests.swift */; }; 17 | 32F0FC8D1ED0A062001DE2F4 /* FloatingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32F0FC8C1ED0A062001DE2F4 /* FloatingView.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 32C9881A1EBFDED6004028A6 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 32C987FD1EBFDECC004028A6 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 32C988041EBFDECC004028A6; 26 | remoteInfo = FloatingButton; 27 | }; 28 | 32C988251EBFDED7004028A6 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 32C987FD1EBFDECC004028A6 /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 32C988041EBFDECC004028A6; 33 | remoteInfo = FloatingButton; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 32C988051EBFDECC004028A6 /* FloatingButton.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FloatingButton.app; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 32C988081EBFDECC004028A6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 40 | 32C9880A1EBFDECD004028A6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 41 | 32C9880D1EBFDECD004028A6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 32C9880F1EBFDECD004028A6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 32C988121EBFDECE004028A6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 32C988141EBFDECE004028A6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | 32C988191EBFDED6004028A6 /* FloatingButtonTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FloatingButtonTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 32C9881D1EBFDED6004028A6 /* FloatingButtonTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingButtonTests.swift; sourceTree = ""; }; 47 | 32C9881F1EBFDED7004028A6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 32C988241EBFDED7004028A6 /* FloatingButtonUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FloatingButtonUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 32C988281EBFDED7004028A6 /* FloatingButtonUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingButtonUITests.swift; sourceTree = ""; }; 50 | 32C9882A1EBFDED7004028A6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 32F0FC8C1ED0A062001DE2F4 /* FloatingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FloatingView.swift; path = Classes/FloatingView.swift; sourceTree = SOURCE_ROOT; }; 52 | /* End PBXFileReference section */ 53 | 54 | /* Begin PBXFrameworksBuildPhase section */ 55 | 32C988021EBFDECC004028A6 /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | 32C988161EBFDED6004028A6 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | 32C988211EBFDED7004028A6 /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | /* End PBXFrameworksBuildPhase section */ 77 | 78 | /* Begin PBXGroup section */ 79 | 32838EF71ECB82EF000B78EB /* Classes */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 32F0FC8C1ED0A062001DE2F4 /* FloatingView.swift */, 83 | ); 84 | name = Classes; 85 | path = FloatingView; 86 | sourceTree = SOURCE_ROOT; 87 | }; 88 | 32C987FC1EBFDECC004028A6 = { 89 | isa = PBXGroup; 90 | children = ( 91 | 32C988071EBFDECC004028A6 /* FloatingButton */, 92 | 32C9881C1EBFDED6004028A6 /* FloatingButtonTests */, 93 | 32C988271EBFDED7004028A6 /* FloatingButtonUITests */, 94 | 32C988061EBFDECC004028A6 /* Products */, 95 | ); 96 | sourceTree = ""; 97 | }; 98 | 32C988061EBFDECC004028A6 /* Products */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 32C988051EBFDECC004028A6 /* FloatingButton.app */, 102 | 32C988191EBFDED6004028A6 /* FloatingButtonTests.xctest */, 103 | 32C988241EBFDED7004028A6 /* FloatingButtonUITests.xctest */, 104 | ); 105 | name = Products; 106 | sourceTree = ""; 107 | }; 108 | 32C988071EBFDECC004028A6 /* FloatingButton */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 32838EF71ECB82EF000B78EB /* Classes */, 112 | 32C988081EBFDECC004028A6 /* AppDelegate.swift */, 113 | 32C9880A1EBFDECD004028A6 /* ViewController.swift */, 114 | 32C9880C1EBFDECD004028A6 /* Main.storyboard */, 115 | 32C9880F1EBFDECD004028A6 /* Assets.xcassets */, 116 | 32C988111EBFDECE004028A6 /* LaunchScreen.storyboard */, 117 | 32C988141EBFDECE004028A6 /* Info.plist */, 118 | ); 119 | path = FloatingButton; 120 | sourceTree = ""; 121 | }; 122 | 32C9881C1EBFDED6004028A6 /* FloatingButtonTests */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 32C9881D1EBFDED6004028A6 /* FloatingButtonTests.swift */, 126 | 32C9881F1EBFDED7004028A6 /* Info.plist */, 127 | ); 128 | path = FloatingButtonTests; 129 | sourceTree = ""; 130 | }; 131 | 32C988271EBFDED7004028A6 /* FloatingButtonUITests */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 32C988281EBFDED7004028A6 /* FloatingButtonUITests.swift */, 135 | 32C9882A1EBFDED7004028A6 /* Info.plist */, 136 | ); 137 | path = FloatingButtonUITests; 138 | sourceTree = ""; 139 | }; 140 | /* End PBXGroup section */ 141 | 142 | /* Begin PBXNativeTarget section */ 143 | 32C988041EBFDECC004028A6 /* FloatingButton */ = { 144 | isa = PBXNativeTarget; 145 | buildConfigurationList = 32C9882D1EBFDED7004028A6 /* Build configuration list for PBXNativeTarget "FloatingButton" */; 146 | buildPhases = ( 147 | 32C988011EBFDECC004028A6 /* Sources */, 148 | 32C988021EBFDECC004028A6 /* Frameworks */, 149 | 32C988031EBFDECC004028A6 /* Resources */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | ); 155 | name = FloatingButton; 156 | productName = FloatingButton; 157 | productReference = 32C988051EBFDECC004028A6 /* FloatingButton.app */; 158 | productType = "com.apple.product-type.application"; 159 | }; 160 | 32C988181EBFDED6004028A6 /* FloatingButtonTests */ = { 161 | isa = PBXNativeTarget; 162 | buildConfigurationList = 32C988301EBFDED7004028A6 /* Build configuration list for PBXNativeTarget "FloatingButtonTests" */; 163 | buildPhases = ( 164 | 32C988151EBFDED6004028A6 /* Sources */, 165 | 32C988161EBFDED6004028A6 /* Frameworks */, 166 | 32C988171EBFDED6004028A6 /* Resources */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | 32C9881B1EBFDED6004028A6 /* PBXTargetDependency */, 172 | ); 173 | name = FloatingButtonTests; 174 | productName = FloatingButtonTests; 175 | productReference = 32C988191EBFDED6004028A6 /* FloatingButtonTests.xctest */; 176 | productType = "com.apple.product-type.bundle.unit-test"; 177 | }; 178 | 32C988231EBFDED7004028A6 /* FloatingButtonUITests */ = { 179 | isa = PBXNativeTarget; 180 | buildConfigurationList = 32C988331EBFDED7004028A6 /* Build configuration list for PBXNativeTarget "FloatingButtonUITests" */; 181 | buildPhases = ( 182 | 32C988201EBFDED7004028A6 /* Sources */, 183 | 32C988211EBFDED7004028A6 /* Frameworks */, 184 | 32C988221EBFDED7004028A6 /* Resources */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | 32C988261EBFDED7004028A6 /* PBXTargetDependency */, 190 | ); 191 | name = FloatingButtonUITests; 192 | productName = FloatingButtonUITests; 193 | productReference = 32C988241EBFDED7004028A6 /* FloatingButtonUITests.xctest */; 194 | productType = "com.apple.product-type.bundle.ui-testing"; 195 | }; 196 | /* End PBXNativeTarget section */ 197 | 198 | /* Begin PBXProject section */ 199 | 32C987FD1EBFDECC004028A6 /* Project object */ = { 200 | isa = PBXProject; 201 | attributes = { 202 | LastSwiftUpdateCheck = 0820; 203 | LastUpgradeCheck = 0820; 204 | ORGANIZATIONNAME = "Ali Pourhadi"; 205 | TargetAttributes = { 206 | 32C988041EBFDECC004028A6 = { 207 | CreatedOnToolsVersion = 8.2.1; 208 | ProvisioningStyle = Automatic; 209 | }; 210 | 32C988181EBFDED6004028A6 = { 211 | CreatedOnToolsVersion = 8.2.1; 212 | ProvisioningStyle = Automatic; 213 | TestTargetID = 32C988041EBFDECC004028A6; 214 | }; 215 | 32C988231EBFDED7004028A6 = { 216 | CreatedOnToolsVersion = 8.2.1; 217 | ProvisioningStyle = Automatic; 218 | TestTargetID = 32C988041EBFDECC004028A6; 219 | }; 220 | }; 221 | }; 222 | buildConfigurationList = 32C988001EBFDECC004028A6 /* Build configuration list for PBXProject "FloatingButton" */; 223 | compatibilityVersion = "Xcode 3.2"; 224 | developmentRegion = English; 225 | hasScannedForEncodings = 0; 226 | knownRegions = ( 227 | en, 228 | Base, 229 | ); 230 | mainGroup = 32C987FC1EBFDECC004028A6; 231 | productRefGroup = 32C988061EBFDECC004028A6 /* Products */; 232 | projectDirPath = ""; 233 | projectRoot = ""; 234 | targets = ( 235 | 32C988041EBFDECC004028A6 /* FloatingButton */, 236 | 32C988181EBFDED6004028A6 /* FloatingButtonTests */, 237 | 32C988231EBFDED7004028A6 /* FloatingButtonUITests */, 238 | ); 239 | }; 240 | /* End PBXProject section */ 241 | 242 | /* Begin PBXResourcesBuildPhase section */ 243 | 32C988031EBFDECC004028A6 /* Resources */ = { 244 | isa = PBXResourcesBuildPhase; 245 | buildActionMask = 2147483647; 246 | files = ( 247 | 32C988131EBFDECE004028A6 /* LaunchScreen.storyboard in Resources */, 248 | 32C988101EBFDECD004028A6 /* Assets.xcassets in Resources */, 249 | 32C9880E1EBFDECD004028A6 /* Main.storyboard in Resources */, 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | }; 253 | 32C988171EBFDED6004028A6 /* Resources */ = { 254 | isa = PBXResourcesBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | 32C988221EBFDED7004028A6 /* Resources */ = { 261 | isa = PBXResourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | /* End PBXResourcesBuildPhase section */ 268 | 269 | /* Begin PBXSourcesBuildPhase section */ 270 | 32C988011EBFDECC004028A6 /* Sources */ = { 271 | isa = PBXSourcesBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | 32C9880B1EBFDECD004028A6 /* ViewController.swift in Sources */, 275 | 32F0FC8D1ED0A062001DE2F4 /* FloatingView.swift in Sources */, 276 | 32C988091EBFDECC004028A6 /* AppDelegate.swift in Sources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | 32C988151EBFDED6004028A6 /* Sources */ = { 281 | isa = PBXSourcesBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | 32C9881E1EBFDED6004028A6 /* FloatingButtonTests.swift in Sources */, 285 | ); 286 | runOnlyForDeploymentPostprocessing = 0; 287 | }; 288 | 32C988201EBFDED7004028A6 /* Sources */ = { 289 | isa = PBXSourcesBuildPhase; 290 | buildActionMask = 2147483647; 291 | files = ( 292 | 32C988291EBFDED7004028A6 /* FloatingButtonUITests.swift in Sources */, 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | /* End PBXSourcesBuildPhase section */ 297 | 298 | /* Begin PBXTargetDependency section */ 299 | 32C9881B1EBFDED6004028A6 /* PBXTargetDependency */ = { 300 | isa = PBXTargetDependency; 301 | target = 32C988041EBFDECC004028A6 /* FloatingButton */; 302 | targetProxy = 32C9881A1EBFDED6004028A6 /* PBXContainerItemProxy */; 303 | }; 304 | 32C988261EBFDED7004028A6 /* PBXTargetDependency */ = { 305 | isa = PBXTargetDependency; 306 | target = 32C988041EBFDECC004028A6 /* FloatingButton */; 307 | targetProxy = 32C988251EBFDED7004028A6 /* PBXContainerItemProxy */; 308 | }; 309 | /* End PBXTargetDependency section */ 310 | 311 | /* Begin PBXVariantGroup section */ 312 | 32C9880C1EBFDECD004028A6 /* Main.storyboard */ = { 313 | isa = PBXVariantGroup; 314 | children = ( 315 | 32C9880D1EBFDECD004028A6 /* Base */, 316 | ); 317 | name = Main.storyboard; 318 | sourceTree = ""; 319 | }; 320 | 32C988111EBFDECE004028A6 /* LaunchScreen.storyboard */ = { 321 | isa = PBXVariantGroup; 322 | children = ( 323 | 32C988121EBFDECE004028A6 /* Base */, 324 | ); 325 | name = LaunchScreen.storyboard; 326 | sourceTree = ""; 327 | }; 328 | /* End PBXVariantGroup section */ 329 | 330 | /* Begin XCBuildConfiguration section */ 331 | 32C9882B1EBFDED7004028A6 /* Debug */ = { 332 | isa = XCBuildConfiguration; 333 | buildSettings = { 334 | ALWAYS_SEARCH_USER_PATHS = NO; 335 | CLANG_ANALYZER_NONNULL = YES; 336 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 337 | CLANG_CXX_LIBRARY = "libc++"; 338 | CLANG_ENABLE_MODULES = YES; 339 | CLANG_ENABLE_OBJC_ARC = YES; 340 | CLANG_WARN_BOOL_CONVERSION = YES; 341 | CLANG_WARN_CONSTANT_CONVERSION = YES; 342 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 343 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 344 | CLANG_WARN_EMPTY_BODY = YES; 345 | CLANG_WARN_ENUM_CONVERSION = YES; 346 | CLANG_WARN_INFINITE_RECURSION = YES; 347 | CLANG_WARN_INT_CONVERSION = YES; 348 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 349 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 350 | CLANG_WARN_UNREACHABLE_CODE = YES; 351 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 352 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 353 | COPY_PHASE_STRIP = NO; 354 | DEBUG_INFORMATION_FORMAT = dwarf; 355 | ENABLE_STRICT_OBJC_MSGSEND = YES; 356 | ENABLE_TESTABILITY = YES; 357 | GCC_C_LANGUAGE_STANDARD = gnu99; 358 | GCC_DYNAMIC_NO_PIC = NO; 359 | GCC_NO_COMMON_BLOCKS = YES; 360 | GCC_OPTIMIZATION_LEVEL = 0; 361 | GCC_PREPROCESSOR_DEFINITIONS = ( 362 | "DEBUG=1", 363 | "$(inherited)", 364 | ); 365 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 366 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 367 | GCC_WARN_UNDECLARED_SELECTOR = YES; 368 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 369 | GCC_WARN_UNUSED_FUNCTION = YES; 370 | GCC_WARN_UNUSED_VARIABLE = YES; 371 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 372 | MTL_ENABLE_DEBUG_INFO = YES; 373 | ONLY_ACTIVE_ARCH = YES; 374 | SDKROOT = iphoneos; 375 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 376 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 377 | }; 378 | name = Debug; 379 | }; 380 | 32C9882C1EBFDED7004028A6 /* Release */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ALWAYS_SEARCH_USER_PATHS = NO; 384 | CLANG_ANALYZER_NONNULL = YES; 385 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 386 | CLANG_CXX_LIBRARY = "libc++"; 387 | CLANG_ENABLE_MODULES = YES; 388 | CLANG_ENABLE_OBJC_ARC = YES; 389 | CLANG_WARN_BOOL_CONVERSION = YES; 390 | CLANG_WARN_CONSTANT_CONVERSION = YES; 391 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 392 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 393 | CLANG_WARN_EMPTY_BODY = YES; 394 | CLANG_WARN_ENUM_CONVERSION = YES; 395 | CLANG_WARN_INFINITE_RECURSION = YES; 396 | CLANG_WARN_INT_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 399 | CLANG_WARN_UNREACHABLE_CODE = YES; 400 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 401 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 402 | COPY_PHASE_STRIP = NO; 403 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 404 | ENABLE_NS_ASSERTIONS = NO; 405 | ENABLE_STRICT_OBJC_MSGSEND = YES; 406 | GCC_C_LANGUAGE_STANDARD = gnu99; 407 | GCC_NO_COMMON_BLOCKS = YES; 408 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 409 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 410 | GCC_WARN_UNDECLARED_SELECTOR = YES; 411 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 412 | GCC_WARN_UNUSED_FUNCTION = YES; 413 | GCC_WARN_UNUSED_VARIABLE = YES; 414 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 415 | MTL_ENABLE_DEBUG_INFO = NO; 416 | SDKROOT = iphoneos; 417 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 418 | VALIDATE_PRODUCT = YES; 419 | }; 420 | name = Release; 421 | }; 422 | 32C9882E1EBFDED7004028A6 /* Debug */ = { 423 | isa = XCBuildConfiguration; 424 | buildSettings = { 425 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 426 | INFOPLIST_FILE = FloatingButton/Info.plist; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 428 | PRODUCT_BUNDLE_IDENTIFIER = com.AliPourhadi.FloatingButton; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | SWIFT_VERSION = 3.0; 431 | }; 432 | name = Debug; 433 | }; 434 | 32C9882F1EBFDED7004028A6 /* Release */ = { 435 | isa = XCBuildConfiguration; 436 | buildSettings = { 437 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 438 | INFOPLIST_FILE = FloatingButton/Info.plist; 439 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 440 | PRODUCT_BUNDLE_IDENTIFIER = com.AliPourhadi.FloatingButton; 441 | PRODUCT_NAME = "$(TARGET_NAME)"; 442 | SWIFT_VERSION = 3.0; 443 | }; 444 | name = Release; 445 | }; 446 | 32C988311EBFDED7004028A6 /* Debug */ = { 447 | isa = XCBuildConfiguration; 448 | buildSettings = { 449 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 450 | BUNDLE_LOADER = "$(TEST_HOST)"; 451 | INFOPLIST_FILE = FloatingButtonTests/Info.plist; 452 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 453 | PRODUCT_BUNDLE_IDENTIFIER = com.AliPourhadi.FloatingButtonTests; 454 | PRODUCT_NAME = "$(TARGET_NAME)"; 455 | SWIFT_VERSION = 3.0; 456 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FloatingButton.app/FloatingButton"; 457 | }; 458 | name = Debug; 459 | }; 460 | 32C988321EBFDED7004028A6 /* Release */ = { 461 | isa = XCBuildConfiguration; 462 | buildSettings = { 463 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 464 | BUNDLE_LOADER = "$(TEST_HOST)"; 465 | INFOPLIST_FILE = FloatingButtonTests/Info.plist; 466 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 467 | PRODUCT_BUNDLE_IDENTIFIER = com.AliPourhadi.FloatingButtonTests; 468 | PRODUCT_NAME = "$(TARGET_NAME)"; 469 | SWIFT_VERSION = 3.0; 470 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FloatingButton.app/FloatingButton"; 471 | }; 472 | name = Release; 473 | }; 474 | 32C988341EBFDED7004028A6 /* Debug */ = { 475 | isa = XCBuildConfiguration; 476 | buildSettings = { 477 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 478 | INFOPLIST_FILE = FloatingButtonUITests/Info.plist; 479 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 480 | PRODUCT_BUNDLE_IDENTIFIER = com.AliPourhadi.FloatingButtonUITests; 481 | PRODUCT_NAME = "$(TARGET_NAME)"; 482 | SWIFT_VERSION = 3.0; 483 | TEST_TARGET_NAME = FloatingButton; 484 | }; 485 | name = Debug; 486 | }; 487 | 32C988351EBFDED7004028A6 /* Release */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 491 | INFOPLIST_FILE = FloatingButtonUITests/Info.plist; 492 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 493 | PRODUCT_BUNDLE_IDENTIFIER = com.AliPourhadi.FloatingButtonUITests; 494 | PRODUCT_NAME = "$(TARGET_NAME)"; 495 | SWIFT_VERSION = 3.0; 496 | TEST_TARGET_NAME = FloatingButton; 497 | }; 498 | name = Release; 499 | }; 500 | /* End XCBuildConfiguration section */ 501 | 502 | /* Begin XCConfigurationList section */ 503 | 32C988001EBFDECC004028A6 /* Build configuration list for PBXProject "FloatingButton" */ = { 504 | isa = XCConfigurationList; 505 | buildConfigurations = ( 506 | 32C9882B1EBFDED7004028A6 /* Debug */, 507 | 32C9882C1EBFDED7004028A6 /* Release */, 508 | ); 509 | defaultConfigurationIsVisible = 0; 510 | defaultConfigurationName = Release; 511 | }; 512 | 32C9882D1EBFDED7004028A6 /* Build configuration list for PBXNativeTarget "FloatingButton" */ = { 513 | isa = XCConfigurationList; 514 | buildConfigurations = ( 515 | 32C9882E1EBFDED7004028A6 /* Debug */, 516 | 32C9882F1EBFDED7004028A6 /* Release */, 517 | ); 518 | defaultConfigurationIsVisible = 0; 519 | defaultConfigurationName = Release; 520 | }; 521 | 32C988301EBFDED7004028A6 /* Build configuration list for PBXNativeTarget "FloatingButtonTests" */ = { 522 | isa = XCConfigurationList; 523 | buildConfigurations = ( 524 | 32C988311EBFDED7004028A6 /* Debug */, 525 | 32C988321EBFDED7004028A6 /* Release */, 526 | ); 527 | defaultConfigurationIsVisible = 0; 528 | defaultConfigurationName = Release; 529 | }; 530 | 32C988331EBFDED7004028A6 /* Build configuration list for PBXNativeTarget "FloatingButtonUITests" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | 32C988341EBFDED7004028A6 /* Debug */, 534 | 32C988351EBFDED7004028A6 /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | defaultConfigurationName = Release; 538 | }; 539 | /* End XCConfigurationList section */ 540 | }; 541 | rootObject = 32C987FD1EBFDECC004028A6 /* Project object */; 542 | } 543 | -------------------------------------------------------------------------------- /FloatingButton.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FloatingButton/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // FloatingButton 4 | // 5 | // Created by Ali Pourhadi on 2017-05-07. 6 | // Copyright © 2017 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /FloatingButton/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /FloatingButton/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /FloatingButton/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 35 | 46 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /FloatingButton/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /FloatingButton/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // FloatingButton 4 | // 5 | // Created by Ali Pourhadi on 2017-05-07. 6 | // Copyright © 2017 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | lazy var floatingButton : FloatingView = { 14 | let normalButton:UIButton = UIButton(type: UIButtonType.system) 15 | normalButton.backgroundColor = .red 16 | normalButton.frame = CGRect(x: 0, y: 0, width: 100, height: 100) 17 | normalButton.layer.cornerRadius = 50 18 | normalButton.addTarget(self, action: #selector(ViewController.printer), for: .touchUpInside) 19 | var floatingView = FloatingView(with: normalButton) 20 | floatingView.delegate = self 21 | return floatingView 22 | }() 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | // Do any additional setup after loading the view, typically from a nib. 27 | } 28 | 29 | override func viewDidAppear(_ animated: Bool) { 30 | floatingButton.show() 31 | } 32 | 33 | override func didReceiveMemoryWarning() { 34 | super.didReceiveMemoryWarning() 35 | // Dispose of any resources that can be recreated. 36 | } 37 | 38 | func printer() { 39 | print("Button Called") 40 | } 41 | 42 | @IBAction func show(_ sender: Any) { 43 | self.floatingButton.show() 44 | } 45 | 46 | @IBAction func hide(_ sender: Any) { 47 | self.floatingButton.hide() 48 | } 49 | 50 | } 51 | 52 | extension ViewController:FloatingViewDelegate { 53 | 54 | func viewDraggingDidBegin(view: UIView, in window: UIWindow?) { 55 | UIView.animate(withDuration: 0.4) { 56 | view.alpha = 0.8 57 | } 58 | } 59 | 60 | func viewDraggingDidEnd(view: UIView, in window: UIWindow?) { 61 | (view as? UIButton)?.cancelTracking(with: nil) 62 | UIView.animate(withDuration: 0.4) { 63 | view.alpha = 1.0 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /FloatingButtonTests/FloatingButtonTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FloatingButtonTests.swift 3 | // FloatingButtonTests 4 | // 5 | // Created by Ali Pourhadi on 2017-05-07. 6 | // Copyright © 2017 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import FloatingButton 11 | 12 | class FloatingButtonTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /FloatingButtonTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /FloatingButtonUITests/FloatingButtonUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FloatingButtonUITests.swift 3 | // FloatingButtonUITests 4 | // 5 | // Created by Ali Pourhadi on 2017-05-07. 6 | // Copyright © 2017 Ali Pourhadi. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class FloatingButtonUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /FloatingButtonUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /FloatingView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint FloatingView.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "FloatingView" 19 | s.version = "0.0.3" 20 | s.summary = "Floating Dragable View" 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = "Dragable,Floating,Movable,FloatingView,FloatingButton" 28 | 29 | s.homepage = "https://github.com/PersianDevelopers/FloatingView" 30 | s.screenshots = "https://raw.githubusercontent.com/PersianDevelopers/FloatingView/master/Screenshot/screen.gif" 31 | 32 | 33 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 34 | # 35 | # Licensing your code is important. See http://choosealicense.com for more info. 36 | # CocoaPods will detect a license file if there is a named LICENSE* 37 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 38 | # 39 | 40 | s.license = "MIT" 41 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 42 | 43 | 44 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 45 | # 46 | # Specify the authors of the library, with email addresses. Email addresses 47 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 48 | # accepts just a name if you'd rather not provide an email address. 49 | # 50 | # Specify a social_media_url where others can refer to, for example a twitter 51 | # profile URL. 52 | # 53 | 54 | s.author = { "Ali Pourhadi" => "Ali.Pourhadi@gmail.com" } 55 | # Or just: s.author = "Ali Pourhadi" 56 | # s.social_media_url = "http://twitter.com/Ali Pourhadi" 57 | 58 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 59 | # 60 | # If this Pod runs only on iOS or OS X, then specify the platform and 61 | # the deployment target. You can optionally include the target after the platform. 62 | # 63 | 64 | s.platform = :ios 65 | # s.platform = :ios, "5.0" 66 | 67 | # When using multiple platforms 68 | s.ios.deployment_target = "8.0" 69 | # s.osx.deployment_target = "10.7" 70 | # s.watchos.deployment_target = "2.0" 71 | # s.tvos.deployment_target = "9.0" 72 | 73 | 74 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 75 | # 76 | # Specify the location from where the source should be retrieved. 77 | # Supports git, hg, bzr, svn and HTTP. 78 | # 79 | 80 | s.source = { :git => "https://github.com/PersianDevelopers/FloatingView.git", :tag => "#{s.version}" } 81 | 82 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 83 | # 84 | # CocoaPods is smart about how it includes source code. For source files 85 | # giving a folder will include any swift, h, m, mm, c & cpp files. 86 | # For header files it will include any header in the folder. 87 | # Not including the public_header_files will make all headers public. 88 | # 89 | 90 | s.source_files = "Classes","Classes/**/" 91 | # s.exclude_files = "Classes/Exclude" 92 | 93 | # s.public_header_files = "Classes/**/*.h" 94 | 95 | 96 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 97 | # 98 | # A list of resources included with the Pod. These are copied into the 99 | # target bundle with a build phase script. Anything else will be cleaned. 100 | # You can preserve files from being cleaned, please don't preserve 101 | # non-essential files like tests, examples and documentation. 102 | # 103 | 104 | # s.resource = "icon.png" 105 | # s.resources = "Resources/*.png" 106 | 107 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 108 | 109 | 110 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 111 | # 112 | # Link your library with frameworks, or libraries. Libraries do not include 113 | # the lib prefix of their name. 114 | # 115 | 116 | # s.framework = "SomeFramework" 117 | # s.frameworks = "SomeFramework", "AnotherFramework" 118 | 119 | # s.library = "iconv" 120 | # s.libraries = "iconv", "xml2" 121 | 122 | 123 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 124 | # 125 | # If your library depends on compiler flags you can set them in the xcconfig hash 126 | # where they will only apply to your library. If you depend on other Podspecs 127 | # you can include multiple dependencies to ensure it works. 128 | 129 | # s.requires_arc = true 130 | 131 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 132 | # s.dependency "JSONKit", "~> 1.4" 133 | 134 | end 135 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ali Pourhadi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Demo](https://raw.githubusercontent.com/PersianDevelopers/FloatingView/master/Screenshot/screen.gif) 2 | 3 | # FloatingView 4 | 5 | Next time that an android guy/girl ask you to create a floating button, you have something to show. 6 | Floating View is a view on top of all views. you can have navigation controller, Tabbar contoller or anything. it goes on top of everyview and will be presented everywhere. 7 | 8 | # Installation with CocoaPods 9 | 10 | ```ruby 11 | pod 'FloatingView', '~> 0.0.3' 12 | ``` 13 | 14 | # Plug and Play 15 | 16 | Add FloatingView.swift to your Project 17 | Create an instance of FloatingView with your custom view ( UIButton / UIView / .... ) 18 | Call .show method in order to show your view 19 | Call .hide to hide your view 20 | 21 | # Requirements 22 | + Swift 3.0 23 | 24 | # Author 25 | Ali Pourhadi, ali.pourhadi@gmail.com 26 | 27 | # License 28 | FloatingView is available under the MIT license. See the LICENSE file for more info. 29 | -------------------------------------------------------------------------------- /Screenshot/screen.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PersianDevelopers/FloatingView/12c0139e1d1562c307550aecf63708570bdff2e5/Screenshot/screen.gif --------------------------------------------------------------------------------