├── Classes └── SFSwiftNotification.swift ├── Gif ├── SFSwiftNotification.gif ├── SFSwiftNotificationBlue.gif └── SFSwiftNotificationTap.gif ├── LICENSE ├── README.md ├── SFSwiftNotification.podspec ├── SFSwiftNotification.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── simone.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── SFSwiftNotification.xcscheme │ └── xcschememanagement.plist ├── SFSwiftNotification ├── AppDelegate.swift ├── Base.lproj │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Info.plist ├── LaunchScreen.storyboard └── ViewController.swift └── SFSwiftNotificationTests ├── Info.plist └── SFSwiftNotificationTests.swift /Classes/SFSwiftNotification.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SFSwiftNotification.swift 3 | // SFSwiftNotification 4 | // 5 | // Created by Simone Ferrini on 13/07/14. 6 | // Copyright (c) 2016 sferrini. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum AnimationType { 12 | case Collision 13 | case Bounce 14 | } 15 | 16 | enum AnimationDirection { 17 | case TopToBottom 18 | case LeftToRight 19 | case RightToLeft 20 | } 21 | 22 | struct AnimationSettings { 23 | var duration: NSTimeInterval = 0.5 24 | var delay: NSTimeInterval = 0 25 | var damping: CGFloat = 0.6 26 | var velocity: CGFloat = 0.9 27 | var elasticity: CGFloat = 0.3 28 | } 29 | 30 | protocol SFSwiftNotificationProtocol { 31 | func didNotifyFinishedAnimation(results: Bool) 32 | func didTapNotification() 33 | } 34 | 35 | class SFSwiftNotification: UIView { 36 | 37 | var label = UILabel() 38 | 39 | private var animationType: AnimationType? 40 | private var animationSettings = AnimationSettings() 41 | private var direction: AnimationDirection? 42 | private var dynamicAnimator = UIDynamicAnimator() 43 | private var delegate: SFSwiftNotificationProtocol? 44 | private var canNotify = true 45 | private var offScreenFrame = CGRect() 46 | private var toFrame = CGRect() 47 | private var initialFrame = CGRect() 48 | private var delay = NSTimeInterval() 49 | 50 | init(frame: CGRect, title: String?, animationType: AnimationType, direction: AnimationDirection, delegate: SFSwiftNotificationProtocol?) { 51 | super.init(frame: frame) 52 | 53 | self.animationType = animationType 54 | self.direction = direction 55 | self.delegate = delegate 56 | self.initialFrame = frame 57 | 58 | label = UILabel(frame: self.frame) 59 | label.text = title 60 | label.textAlignment = NSTextAlignment.Center 61 | self.addSubview(label) 62 | 63 | // Create gesture recognizer to detect notification touches 64 | let tapReconizer = UITapGestureRecognizer() 65 | tapReconizer.addTarget(self, action: "invokeTapAction"); 66 | 67 | // Add Touch recognizer to notification view 68 | self.addGestureRecognizer(tapReconizer) 69 | 70 | offScreen() 71 | } 72 | 73 | required init?(coder aDecoder: NSCoder) { 74 | fatalError("init(coder:) has not been implemented") 75 | } 76 | 77 | func animate(delay: NSTimeInterval) { 78 | 79 | self.toFrame = self.frame 80 | self.delay = delay 81 | 82 | if canNotify { 83 | self.canNotify = false 84 | 85 | switch self.animationType! { 86 | case .Collision: 87 | setupCollisionAnimation(self.initialFrame) 88 | 89 | case .Bounce: 90 | setupBounceAnimation(self.initialFrame, delay: delay) 91 | } 92 | } 93 | } 94 | 95 | func invokeTapAction() { 96 | 97 | self.delegate!.didTapNotification() 98 | self.canNotify = true 99 | } 100 | 101 | private func offScreen() { 102 | 103 | self.offScreenFrame = self.frame 104 | 105 | switch direction! { 106 | case .TopToBottom: 107 | self.offScreenFrame.origin.y = -self.frame.size.height 108 | case .LeftToRight: 109 | self.offScreenFrame.origin.x = -self.frame.size.width 110 | case .RightToLeft: 111 | self.offScreenFrame.origin.x = +self.frame.size.width 112 | } 113 | 114 | self.frame = offScreenFrame 115 | } 116 | 117 | private func setupCollisionAnimation(toFrame: CGRect) { 118 | 119 | self.dynamicAnimator = UIDynamicAnimator(referenceView: self.superview!) 120 | self.dynamicAnimator.delegate = self 121 | 122 | let elasticityBehavior = UIDynamicItemBehavior(items: [self]) 123 | elasticityBehavior.elasticity = animationSettings.elasticity; 124 | self.dynamicAnimator.addBehavior(elasticityBehavior) 125 | 126 | let gravityBehavior = UIGravityBehavior(items: [self]) 127 | self.dynamicAnimator.addBehavior(gravityBehavior) 128 | 129 | let collisionBehavior = UICollisionBehavior(items: [self]) 130 | self.dynamicAnimator.addBehavior(collisionBehavior) 131 | 132 | collisionBehavior.addBoundaryWithIdentifier("BoundaryIdentifierBottom", fromPoint: CGPointMake(-self.frame.width, self.frame.height), toPoint: CGPointMake(self.frame.width*2, self.frame.height)) 133 | 134 | switch self.direction! { 135 | case .TopToBottom: 136 | break 137 | case .LeftToRight: 138 | collisionBehavior.addBoundaryWithIdentifier("BoundaryIdentifierRight", fromPoint: CGPointMake(self.toFrame.width+1, 0), toPoint: CGPointMake(self.toFrame.width+2, self.toFrame.height)) 139 | gravityBehavior.gravityDirection = CGVectorMake(10, 1) 140 | case .RightToLeft: 141 | collisionBehavior.addBoundaryWithIdentifier("BoundaryIdentifierLeft", fromPoint: CGPointMake(-1, 0), toPoint: CGPointMake(-2, self.toFrame.height)) 142 | gravityBehavior.gravityDirection = CGVectorMake(-10, 1) 143 | } 144 | } 145 | 146 | private func setupBounceAnimation(toFrame: CGRect , delay: NSTimeInterval) { 147 | 148 | UIView.animateWithDuration(animationSettings.duration, 149 | delay: animationSettings.delay, 150 | usingSpringWithDamping: animationSettings.damping, 151 | initialSpringVelocity: animationSettings.velocity, 152 | options: ([.BeginFromCurrentState, .AllowUserInteraction]), 153 | animations:{ 154 | self.frame = toFrame 155 | }, completion: { 156 | (value: Bool) in 157 | self.hide(toFrame, delay: delay) 158 | } 159 | ) 160 | } 161 | 162 | private func hide(toFrame: CGRect, delay: NSTimeInterval) { 163 | 164 | UIView.animateWithDuration(animationSettings.duration, 165 | delay: delay, 166 | usingSpringWithDamping: animationSettings.damping, 167 | initialSpringVelocity: animationSettings.velocity, 168 | options: ([.BeginFromCurrentState, .AllowUserInteraction]), 169 | animations:{ 170 | self.frame = self.offScreenFrame 171 | }, completion: { 172 | (value: Bool) in 173 | self.delegate!.didNotifyFinishedAnimation(true) 174 | self.canNotify = true 175 | } 176 | ) 177 | } 178 | } 179 | 180 | extension SFSwiftNotification: UIDynamicAnimatorDelegate { 181 | 182 | func dynamicAnimatorDidPause(animator: UIDynamicAnimator) { 183 | 184 | hide(self.toFrame, delay: self.delay) 185 | } 186 | 187 | } 188 | -------------------------------------------------------------------------------- /Gif/SFSwiftNotification.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sferrini/SFSwiftNotification/d85190bf8e1b03b40dd1b198454b0886f261ff6a/Gif/SFSwiftNotification.gif -------------------------------------------------------------------------------- /Gif/SFSwiftNotificationBlue.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sferrini/SFSwiftNotification/d85190bf8e1b03b40dd1b198454b0886f261ff6a/Gif/SFSwiftNotificationBlue.gif -------------------------------------------------------------------------------- /Gif/SFSwiftNotificationTap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sferrini/SFSwiftNotification/d85190bf8e1b03b40dd1b198454b0886f261ff6a/Gif/SFSwiftNotificationTap.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simone Ferrini 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 13 | all 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 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SFSwiftNotification 2 | ============= 3 | 4 | Simple custom user notifications 5 | 6 | (**DEPRECATED AND NO LONGER MAINTAINED.**) 7 | 8 | Install 9 | -------------------- 10 | 11 | * Copy the file ```SFSwiftNotification.swift``` into your project. 12 | 13 | 14 | Usage 15 | -------------------- 16 | 17 | 18 | In your ViewController 19 | 20 | ```swift 21 | var notificationView: SFSwiftNotification? 22 | ``` 23 | 24 | In ```viewDidLoad()``` 25 | 26 | ```swift 27 | notificationView = SFSwiftNotification(frame: CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 50), 28 | title: "This is an SFSwiftNotification", 29 | animationType: .Collision, 30 | direction: .RightToLeft, 31 | delegate: self) 32 | 33 | notificationView!.backgroundColor = UIColor.orangeColor() 34 | notificationView!.label.textColor = UIColor.whiteColor() 35 | 36 | self.view.addSubview(notificationView!) 37 | ``` 38 | 39 | To start the notification: 40 | 41 | ```swift 42 | @IBAction func notify(sender : AnyObject) { 43 | 44 | self.notificationView!.animate(1) 45 | } 46 | ``` 47 | 48 | Settings 49 | -------------------- 50 | 51 | AnimationTypes: 52 | 53 | ```swift 54 | .Collision 55 | .Bounce 56 | ``` 57 | 58 | Directions: 59 | 60 | ```swift 61 | .TopToBottom 62 | .LeftToRight 63 | .RightToLeft 64 | ``` 65 | 66 | Screen 67 | -------------------- 68 | 69 | ![Demo DEFAULT](https://raw.github.com/sferrini/SFSwiftNotification/master/Gif/SFSwiftNotificationBlue.gif) 70 | 71 | ![Demo DEFAULT](https://raw.github.com/sferrini/SFSwiftNotification/master/Gif/SFSwiftNotification.gif) 72 | 73 | ![Demo DEFAULT](https://raw.github.com/oduwa/SFSwiftNotification/master/Gif/SFSwiftNotificationTap.gif) 74 | -------------------------------------------------------------------------------- /SFSwiftNotification.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "SFSwiftNotification" 3 | s.version = "0.0.3" 4 | s.summary = "Simple custom user notifications (UIView subclass)" 5 | s.homepage = "https://github.com/sferrini/SFSwiftNotification" 6 | s.license = { :type => "MIT", :file => "LICENSE" } 7 | s.author = { "Simone Ferrini" => "sferrini@hotmail.it" } 8 | s.source = { :git => "https://github.com/sferrini/SFSwiftNotification.git", :tag => s.version.to_s } 9 | s.social_media_url = 'https://twitter.com/Simone_Ferrini' 10 | s.platform = :ios, '7.0' 11 | s.requires_arc = true 12 | s.source_files = 'Classes/*.swift' 13 | end 14 | -------------------------------------------------------------------------------- /SFSwiftNotification.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 88E566011C81D9AD004B415F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 88E566001C81D9AD004B415F /* LaunchScreen.storyboard */; }; 11 | FC2601B31972D15200301002 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2601B21972D15200301002 /* AppDelegate.swift */; }; 12 | FC2601B51972D15200301002 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2601B41972D15200301002 /* ViewController.swift */; }; 13 | FC2601B81972D15200301002 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC2601B61972D15200301002 /* Main.storyboard */; }; 14 | FC2601BA1972D15200301002 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FC2601B91972D15200301002 /* Images.xcassets */; }; 15 | FC2601C61972D15300301002 /* SFSwiftNotificationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2601C51972D15300301002 /* SFSwiftNotificationTests.swift */; }; 16 | FC2601D31972D26500301002 /* SFSwiftNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2601D21972D26500301002 /* SFSwiftNotification.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | FC2601C01972D15300301002 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = FC2601A51972D15200301002 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = FC2601AC1972D15200301002; 25 | remoteInfo = SFSwiftNotification; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 88E566001C81D9AD004B415F /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; 31 | FC2601AD1972D15200301002 /* SFSwiftNotification.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SFSwiftNotification.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | FC2601B11972D15200301002 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | FC2601B21972D15200301002 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | FC2601B41972D15200301002 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 35 | FC2601B71972D15200301002 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 36 | FC2601B91972D15200301002 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 37 | FC2601BF1972D15300301002 /* SFSwiftNotificationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SFSwiftNotificationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | FC2601C41972D15300301002 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | FC2601C51972D15300301002 /* SFSwiftNotificationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SFSwiftNotificationTests.swift; sourceTree = ""; }; 40 | FC2601D21972D26500301002 /* SFSwiftNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SFSwiftNotification.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | FC2601AA1972D15200301002 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | FC2601BC1972D15300301002 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | FC2601A41972D15200301002 = { 62 | isa = PBXGroup; 63 | children = ( 64 | FC2601AF1972D15200301002 /* SFSwiftNotification */, 65 | FC2601C21972D15300301002 /* SFSwiftNotificationTests */, 66 | FC2601AE1972D15200301002 /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | FC2601AE1972D15200301002 /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | FC2601AD1972D15200301002 /* SFSwiftNotification.app */, 74 | FC2601BF1972D15300301002 /* SFSwiftNotificationTests.xctest */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | FC2601AF1972D15200301002 /* SFSwiftNotification */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | FC2601D11972D25000301002 /* Classes */, 83 | FC2601B21972D15200301002 /* AppDelegate.swift */, 84 | FC2601B41972D15200301002 /* ViewController.swift */, 85 | FC2601B61972D15200301002 /* Main.storyboard */, 86 | 88E566001C81D9AD004B415F /* LaunchScreen.storyboard */, 87 | FC2601B91972D15200301002 /* Images.xcassets */, 88 | FC2601B01972D15200301002 /* Supporting Files */, 89 | ); 90 | path = SFSwiftNotification; 91 | sourceTree = ""; 92 | }; 93 | FC2601B01972D15200301002 /* Supporting Files */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | FC2601B11972D15200301002 /* Info.plist */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | FC2601C21972D15300301002 /* SFSwiftNotificationTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | FC2601C51972D15300301002 /* SFSwiftNotificationTests.swift */, 105 | FC2601C31972D15300301002 /* Supporting Files */, 106 | ); 107 | path = SFSwiftNotificationTests; 108 | sourceTree = ""; 109 | }; 110 | FC2601C31972D15300301002 /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | FC2601C41972D15300301002 /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | FC2601D11972D25000301002 /* Classes */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | FC2601D21972D26500301002 /* SFSwiftNotification.swift */, 122 | ); 123 | path = Classes; 124 | sourceTree = SOURCE_ROOT; 125 | }; 126 | /* End PBXGroup section */ 127 | 128 | /* Begin PBXNativeTarget section */ 129 | FC2601AC1972D15200301002 /* SFSwiftNotification */ = { 130 | isa = PBXNativeTarget; 131 | buildConfigurationList = FC2601C91972D15300301002 /* Build configuration list for PBXNativeTarget "SFSwiftNotification" */; 132 | buildPhases = ( 133 | FC2601A91972D15200301002 /* Sources */, 134 | FC2601AA1972D15200301002 /* Frameworks */, 135 | FC2601AB1972D15200301002 /* Resources */, 136 | ); 137 | buildRules = ( 138 | ); 139 | dependencies = ( 140 | ); 141 | name = SFSwiftNotification; 142 | productName = SFSwiftNotification; 143 | productReference = FC2601AD1972D15200301002 /* SFSwiftNotification.app */; 144 | productType = "com.apple.product-type.application"; 145 | }; 146 | FC2601BE1972D15300301002 /* SFSwiftNotificationTests */ = { 147 | isa = PBXNativeTarget; 148 | buildConfigurationList = FC2601CC1972D15300301002 /* Build configuration list for PBXNativeTarget "SFSwiftNotificationTests" */; 149 | buildPhases = ( 150 | FC2601BB1972D15300301002 /* Sources */, 151 | FC2601BC1972D15300301002 /* Frameworks */, 152 | FC2601BD1972D15300301002 /* Resources */, 153 | ); 154 | buildRules = ( 155 | ); 156 | dependencies = ( 157 | FC2601C11972D15300301002 /* PBXTargetDependency */, 158 | ); 159 | name = SFSwiftNotificationTests; 160 | productName = SFSwiftNotificationTests; 161 | productReference = FC2601BF1972D15300301002 /* SFSwiftNotificationTests.xctest */; 162 | productType = "com.apple.product-type.bundle.unit-test"; 163 | }; 164 | /* End PBXNativeTarget section */ 165 | 166 | /* Begin PBXProject section */ 167 | FC2601A51972D15200301002 /* Project object */ = { 168 | isa = PBXProject; 169 | attributes = { 170 | LastSwiftMigration = 0720; 171 | LastSwiftUpdateCheck = 0720; 172 | LastUpgradeCheck = 0720; 173 | ORGANIZATIONNAME = sferrini; 174 | TargetAttributes = { 175 | FC2601AC1972D15200301002 = { 176 | CreatedOnToolsVersion = 6.0; 177 | }; 178 | FC2601BE1972D15300301002 = { 179 | CreatedOnToolsVersion = 6.0; 180 | TestTargetID = FC2601AC1972D15200301002; 181 | }; 182 | }; 183 | }; 184 | buildConfigurationList = FC2601A81972D15200301002 /* Build configuration list for PBXProject "SFSwiftNotification" */; 185 | compatibilityVersion = "Xcode 3.2"; 186 | developmentRegion = English; 187 | hasScannedForEncodings = 0; 188 | knownRegions = ( 189 | en, 190 | Base, 191 | ); 192 | mainGroup = FC2601A41972D15200301002; 193 | productRefGroup = FC2601AE1972D15200301002 /* Products */; 194 | projectDirPath = ""; 195 | projectRoot = ""; 196 | targets = ( 197 | FC2601AC1972D15200301002 /* SFSwiftNotification */, 198 | FC2601BE1972D15300301002 /* SFSwiftNotificationTests */, 199 | ); 200 | }; 201 | /* End PBXProject section */ 202 | 203 | /* Begin PBXResourcesBuildPhase section */ 204 | FC2601AB1972D15200301002 /* Resources */ = { 205 | isa = PBXResourcesBuildPhase; 206 | buildActionMask = 2147483647; 207 | files = ( 208 | 88E566011C81D9AD004B415F /* LaunchScreen.storyboard in Resources */, 209 | FC2601B81972D15200301002 /* Main.storyboard in Resources */, 210 | FC2601BA1972D15200301002 /* Images.xcassets in Resources */, 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | }; 214 | FC2601BD1972D15300301002 /* Resources */ = { 215 | isa = PBXResourcesBuildPhase; 216 | buildActionMask = 2147483647; 217 | files = ( 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | /* End PBXResourcesBuildPhase section */ 222 | 223 | /* Begin PBXSourcesBuildPhase section */ 224 | FC2601A91972D15200301002 /* Sources */ = { 225 | isa = PBXSourcesBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | FC2601B51972D15200301002 /* ViewController.swift in Sources */, 229 | FC2601B31972D15200301002 /* AppDelegate.swift in Sources */, 230 | FC2601D31972D26500301002 /* SFSwiftNotification.swift in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | FC2601BB1972D15300301002 /* Sources */ = { 235 | isa = PBXSourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | FC2601C61972D15300301002 /* SFSwiftNotificationTests.swift in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXSourcesBuildPhase section */ 243 | 244 | /* Begin PBXTargetDependency section */ 245 | FC2601C11972D15300301002 /* PBXTargetDependency */ = { 246 | isa = PBXTargetDependency; 247 | target = FC2601AC1972D15200301002 /* SFSwiftNotification */; 248 | targetProxy = FC2601C01972D15300301002 /* PBXContainerItemProxy */; 249 | }; 250 | /* End PBXTargetDependency section */ 251 | 252 | /* Begin PBXVariantGroup section */ 253 | FC2601B61972D15200301002 /* Main.storyboard */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | FC2601B71972D15200301002 /* Base */, 257 | ); 258 | name = Main.storyboard; 259 | sourceTree = ""; 260 | }; 261 | /* End PBXVariantGroup section */ 262 | 263 | /* Begin XCBuildConfiguration section */ 264 | FC2601C71972D15300301002 /* Debug */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ALWAYS_SEARCH_USER_PATHS = NO; 268 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 269 | CLANG_CXX_LIBRARY = "libc++"; 270 | CLANG_ENABLE_MODULES = YES; 271 | CLANG_ENABLE_OBJC_ARC = YES; 272 | CLANG_WARN_BOOL_CONVERSION = YES; 273 | CLANG_WARN_CONSTANT_CONVERSION = YES; 274 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 275 | CLANG_WARN_EMPTY_BODY = YES; 276 | CLANG_WARN_ENUM_CONVERSION = YES; 277 | CLANG_WARN_INT_CONVERSION = YES; 278 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 279 | CLANG_WARN_UNREACHABLE_CODE = YES; 280 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 281 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 282 | COPY_PHASE_STRIP = NO; 283 | ENABLE_STRICT_OBJC_MSGSEND = YES; 284 | ENABLE_TESTABILITY = YES; 285 | GCC_C_LANGUAGE_STANDARD = gnu99; 286 | GCC_DYNAMIC_NO_PIC = NO; 287 | GCC_OPTIMIZATION_LEVEL = 0; 288 | GCC_PREPROCESSOR_DEFINITIONS = ( 289 | "DEBUG=1", 290 | "$(inherited)", 291 | ); 292 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 293 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 294 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 295 | GCC_WARN_UNDECLARED_SELECTOR = YES; 296 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 297 | GCC_WARN_UNUSED_FUNCTION = YES; 298 | GCC_WARN_UNUSED_VARIABLE = YES; 299 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 300 | METAL_ENABLE_DEBUG_INFO = YES; 301 | ONLY_ACTIVE_ARCH = YES; 302 | SDKROOT = iphoneos; 303 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 304 | }; 305 | name = Debug; 306 | }; 307 | FC2601C81972D15300301002 /* Release */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | ALWAYS_SEARCH_USER_PATHS = NO; 311 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 312 | CLANG_CXX_LIBRARY = "libc++"; 313 | CLANG_ENABLE_MODULES = YES; 314 | CLANG_ENABLE_OBJC_ARC = YES; 315 | CLANG_WARN_BOOL_CONVERSION = YES; 316 | CLANG_WARN_CONSTANT_CONVERSION = YES; 317 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 318 | CLANG_WARN_EMPTY_BODY = YES; 319 | CLANG_WARN_ENUM_CONVERSION = YES; 320 | CLANG_WARN_INT_CONVERSION = YES; 321 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 322 | CLANG_WARN_UNREACHABLE_CODE = YES; 323 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 324 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 325 | COPY_PHASE_STRIP = YES; 326 | ENABLE_NS_ASSERTIONS = NO; 327 | ENABLE_STRICT_OBJC_MSGSEND = YES; 328 | GCC_C_LANGUAGE_STANDARD = gnu99; 329 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 330 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 331 | GCC_WARN_UNDECLARED_SELECTOR = YES; 332 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 333 | GCC_WARN_UNUSED_FUNCTION = YES; 334 | GCC_WARN_UNUSED_VARIABLE = YES; 335 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 336 | METAL_ENABLE_DEBUG_INFO = NO; 337 | SDKROOT = iphoneos; 338 | VALIDATE_PRODUCT = YES; 339 | }; 340 | name = Release; 341 | }; 342 | FC2601CA1972D15300301002 /* Debug */ = { 343 | isa = XCBuildConfiguration; 344 | buildSettings = { 345 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 346 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 347 | INFOPLIST_FILE = SFSwiftNotification/Info.plist; 348 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 349 | PRODUCT_BUNDLE_IDENTIFIER = "com.sferrini.${PRODUCT_NAME:rfc1034identifier}"; 350 | PRODUCT_NAME = "$(TARGET_NAME)"; 351 | }; 352 | name = Debug; 353 | }; 354 | FC2601CB1972D15300301002 /* Release */ = { 355 | isa = XCBuildConfiguration; 356 | buildSettings = { 357 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 358 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 359 | INFOPLIST_FILE = SFSwiftNotification/Info.plist; 360 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 361 | PRODUCT_BUNDLE_IDENTIFIER = "com.sferrini.${PRODUCT_NAME:rfc1034identifier}"; 362 | PRODUCT_NAME = "$(TARGET_NAME)"; 363 | }; 364 | name = Release; 365 | }; 366 | FC2601CD1972D15300301002 /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SFSwiftNotification.app/SFSwiftNotification"; 370 | FRAMEWORK_SEARCH_PATHS = ( 371 | "$(SDKROOT)/Developer/Library/Frameworks", 372 | "$(inherited)", 373 | ); 374 | GCC_PREPROCESSOR_DEFINITIONS = ( 375 | "DEBUG=1", 376 | "$(inherited)", 377 | ); 378 | INFOPLIST_FILE = SFSwiftNotificationTests/Info.plist; 379 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 380 | METAL_ENABLE_DEBUG_INFO = YES; 381 | PRODUCT_BUNDLE_IDENTIFIER = "com.sferrini.${PRODUCT_NAME:rfc1034identifier}"; 382 | PRODUCT_NAME = "$(TARGET_NAME)"; 383 | TEST_HOST = "$(BUNDLE_LOADER)"; 384 | }; 385 | name = Debug; 386 | }; 387 | FC2601CE1972D15300301002 /* Release */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SFSwiftNotification.app/SFSwiftNotification"; 391 | FRAMEWORK_SEARCH_PATHS = ( 392 | "$(SDKROOT)/Developer/Library/Frameworks", 393 | "$(inherited)", 394 | ); 395 | INFOPLIST_FILE = SFSwiftNotificationTests/Info.plist; 396 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 397 | METAL_ENABLE_DEBUG_INFO = NO; 398 | PRODUCT_BUNDLE_IDENTIFIER = "com.sferrini.${PRODUCT_NAME:rfc1034identifier}"; 399 | PRODUCT_NAME = "$(TARGET_NAME)"; 400 | TEST_HOST = "$(BUNDLE_LOADER)"; 401 | }; 402 | name = Release; 403 | }; 404 | /* End XCBuildConfiguration section */ 405 | 406 | /* Begin XCConfigurationList section */ 407 | FC2601A81972D15200301002 /* Build configuration list for PBXProject "SFSwiftNotification" */ = { 408 | isa = XCConfigurationList; 409 | buildConfigurations = ( 410 | FC2601C71972D15300301002 /* Debug */, 411 | FC2601C81972D15300301002 /* Release */, 412 | ); 413 | defaultConfigurationIsVisible = 0; 414 | defaultConfigurationName = Release; 415 | }; 416 | FC2601C91972D15300301002 /* Build configuration list for PBXNativeTarget "SFSwiftNotification" */ = { 417 | isa = XCConfigurationList; 418 | buildConfigurations = ( 419 | FC2601CA1972D15300301002 /* Debug */, 420 | FC2601CB1972D15300301002 /* Release */, 421 | ); 422 | defaultConfigurationIsVisible = 0; 423 | defaultConfigurationName = Release; 424 | }; 425 | FC2601CC1972D15300301002 /* Build configuration list for PBXNativeTarget "SFSwiftNotificationTests" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | FC2601CD1972D15300301002 /* Debug */, 429 | FC2601CE1972D15300301002 /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | /* End XCConfigurationList section */ 435 | }; 436 | rootObject = FC2601A51972D15200301002 /* Project object */; 437 | } 438 | -------------------------------------------------------------------------------- /SFSwiftNotification.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SFSwiftNotification.xcodeproj/xcuserdata/simone.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /SFSwiftNotification.xcodeproj/xcuserdata/simone.xcuserdatad/xcschemes/SFSwiftNotification.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /SFSwiftNotification.xcodeproj/xcuserdata/simone.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SFSwiftNotification.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | FC2601AC1972D15200301002 16 | 17 | primary 18 | 19 | 20 | FC2601BE1972D15300301002 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SFSwiftNotification/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SFSwiftNotification 4 | // 5 | // Created by Simone Ferrini on 13/07/14. 6 | // Copyright (c) 2014 sferrini. 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: [NSObject: AnyObject]?) -> 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 throttle down OpenGL ES frame rates. 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 inactive 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 | -------------------------------------------------------------------------------- /SFSwiftNotification/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /SFSwiftNotification/Images.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" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /SFSwiftNotification/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /SFSwiftNotification/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIStatusBarHidden 34 | 35 | UIViewControllerBasedStatusBarAppearance 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /SFSwiftNotification/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /SFSwiftNotification/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SFSwiftNotification 4 | // 5 | // Created by Simone Ferrini on 13/07/14. 6 | // Copyright (c) 2014 sferrini. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController, SFSwiftNotificationProtocol { 12 | 13 | var notificationView: SFSwiftNotification? 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | notificationView = SFSwiftNotification(frame: CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 50), 19 | title: "This is an SFSwiftNotification", 20 | animationType: .Collision, 21 | direction: .TopToBottom, 22 | delegate: self) 23 | 24 | notificationView!.backgroundColor = UIColor.orangeColor() 25 | notificationView!.label.textColor = UIColor.whiteColor() 26 | 27 | self.view.addSubview(notificationView!) 28 | } 29 | 30 | @IBAction func notify(sender : AnyObject) { 31 | 32 | self.notificationView!.animate(1) 33 | } 34 | 35 | func didNotifyFinishedAnimation(results: Bool) { 36 | 37 | print("SFSwiftNotification finished animation") 38 | } 39 | 40 | func didTapNotification() { 41 | 42 | let tapAlert = UIAlertController(title: "SFSwiftNotification", 43 | message: "You just tapped the notificatoion", 44 | preferredStyle: .Alert) 45 | 46 | tapAlert.addAction(UIAlertAction(title: "OK", 47 | style: .Destructive, 48 | handler: nil)) 49 | 50 | self.presentViewController(tapAlert, animated: true, completion: nil) 51 | } 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /SFSwiftNotificationTests/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SFSwiftNotificationTests/SFSwiftNotificationTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SFSwiftNotificationTests.swift 3 | // SFSwiftNotificationTests 4 | // 5 | // Created by Simone Ferrini on 13/07/14. 6 | // Copyright (c) 2014 sferrini. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class SFSwiftNotificationTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | // This is an example of a functional test case. 25 | XCTAssert(true, "Pass") 26 | } 27 | 28 | func testPerformanceExample() { 29 | // This is an example of a performance test case. 30 | self.measureBlock() { 31 | // Put the code you want to measure the time of here. 32 | } 33 | } 34 | 35 | } 36 | --------------------------------------------------------------------------------