├── .gitignore ├── .swift-version ├── .travis.yml ├── Example ├── Example.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── Example.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Example │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── notice_bar_example.imageset │ │ │ ├── Contents.json │ │ │ ├── notice_bar_attention@2x.png │ │ │ └── notice_bar_attention@3x.png │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── Podfile └── Podfile.lock ├── LICENSE ├── NoticeBar.podspec ├── NoticeBar.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── xcshareddata │ └── xcschemes │ └── NoticeBar.xcscheme ├── NoticeBar ├── Bundle+NoticeBar.swift ├── Images.xcassets │ ├── Contents.json │ ├── notice_bar_attention.imageset │ │ ├── Contents.json │ │ ├── notice_bar_attention@2x.png │ │ └── notice_bar_attention@3x.png │ ├── notice_bar_error.imageset │ │ ├── Contents.json │ │ ├── notice_bar_error@2x.png │ │ └── notice_bar_error@3x.png │ ├── notice_bar_info.imageset │ │ ├── Contents.json │ │ ├── notice_bar_info@2x.png │ │ └── notice_bar_info@3x.png │ └── notice_bar_success.imageset │ │ ├── Contents.json │ │ ├── notice_bar_success@2x.png │ │ └── notice_bar_success@3x.png ├── Info.plist ├── NoticeBar.h └── NoticeBar.swift ├── README.md └── Screenshots ├── notice_bar_atttention.jpg ├── notice_bar_below_status.jpg ├── notice_bar_error.jpg ├── notice_bar_info.jpg ├── notice_bar_navigationbar.jpg ├── notice_bar_statusbar.jpg ├── notice_bar_success.jpg ├── notice_bar_tabbar.jpg ├── pin_notice_view.jpg ├── qq_notice_view_1.jpg └── qq_notice_view_2.jpg /.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 | *.xcuserstate 23 | !NoticeBar.xcscheme 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 | .build/ 40 | 41 | # CocoaPods 42 | # 43 | # We recommend against adding the Pods directory to your .gitignore. However 44 | # you should judge for yourself, the pros and cons are mentioned at: 45 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 46 | # 47 | Pods/ 48 | 49 | # Carthage 50 | # 51 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 52 | # Carthage/Checkouts 53 | 54 | Carthage/Build 55 | 56 | # fastlane 57 | # 58 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 59 | # screenshots whenever they are needed. 60 | # For more information about the recommended setup visit: 61 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 62 | 63 | fastlane/report.xml 64 | fastlane/Preview.html 65 | fastlane/screenshots 66 | fastlane/test_output 67 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode8.1 3 | xcode_project: NoticeBar.xcodeproj 4 | # podfile: Example/Podfile 5 | # before_install: 6 | # - rvm use system 7 | # # - sudo bundle update rake 8 | # - sudo gem install cocoapods 9 | # - pod install --project-directory=Example 10 | 11 | # script: 12 | # - set -0 pipefail && xcodebuild test -workspace Example/Example.xcworkspace -scheme Example iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty 13 | # - pod lib lint 14 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 86F565AD1DFC4E5000193049 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86F565AC1DFC4E5000193049 /* AppDelegate.swift */; }; 11 | 86F565AF1DFC4E5000193049 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86F565AE1DFC4E5000193049 /* ViewController.swift */; }; 12 | 86F565B21DFC4E5000193049 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 86F565B01DFC4E5000193049 /* Main.storyboard */; }; 13 | 86F565B41DFC4E5000193049 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 86F565B31DFC4E5000193049 /* Assets.xcassets */; }; 14 | 86F565B71DFC4E5000193049 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 86F565B51DFC4E5000193049 /* LaunchScreen.storyboard */; }; 15 | D4524E00DFE373ED041ADDE8 /* Pods_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B9074E8DDE1F3FE1A9ADA5A /* Pods_Example.framework */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 1E8FDFC944CD379C91E2ABEA /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = ""; }; 20 | 86F565A91DFC4E5000193049 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 86F565AC1DFC4E5000193049 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 86F565AE1DFC4E5000193049 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 23 | 86F565B11DFC4E5000193049 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 24 | 86F565B31DFC4E5000193049 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 86F565B61DFC4E5000193049 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 26 | 86F565B81DFC4E5000193049 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 9B9074E8DDE1F3FE1A9ADA5A /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | B6F681E5C7FF564654591910 /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 86F565A61DFC4E5000193049 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | D4524E00DFE373ED041ADDE8 /* Pods_Example.framework in Frameworks */, 37 | ); 38 | runOnlyForDeploymentPostprocessing = 0; 39 | }; 40 | /* End PBXFrameworksBuildPhase section */ 41 | 42 | /* Begin PBXGroup section */ 43 | 86F565A01DFC4E5000193049 = { 44 | isa = PBXGroup; 45 | children = ( 46 | 86F565AB1DFC4E5000193049 /* Example */, 47 | 86F565AA1DFC4E5000193049 /* Products */, 48 | A8F75830EE4BD944C69E1D7D /* Pods */, 49 | B5EECB0A217669E6E2EC0B86 /* Frameworks */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 86F565AA1DFC4E5000193049 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 86F565A91DFC4E5000193049 /* Example.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 86F565AB1DFC4E5000193049 /* Example */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 86F565AC1DFC4E5000193049 /* AppDelegate.swift */, 65 | 86F565AE1DFC4E5000193049 /* ViewController.swift */, 66 | 86F565B01DFC4E5000193049 /* Main.storyboard */, 67 | 86F565B31DFC4E5000193049 /* Assets.xcassets */, 68 | 86F565B51DFC4E5000193049 /* LaunchScreen.storyboard */, 69 | 86F565B81DFC4E5000193049 /* Info.plist */, 70 | ); 71 | path = Example; 72 | sourceTree = ""; 73 | }; 74 | A8F75830EE4BD944C69E1D7D /* Pods */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 1E8FDFC944CD379C91E2ABEA /* Pods-Example.debug.xcconfig */, 78 | B6F681E5C7FF564654591910 /* Pods-Example.release.xcconfig */, 79 | ); 80 | name = Pods; 81 | sourceTree = ""; 82 | }; 83 | B5EECB0A217669E6E2EC0B86 /* Frameworks */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 9B9074E8DDE1F3FE1A9ADA5A /* Pods_Example.framework */, 87 | ); 88 | name = Frameworks; 89 | sourceTree = ""; 90 | }; 91 | /* End PBXGroup section */ 92 | 93 | /* Begin PBXNativeTarget section */ 94 | 86F565A81DFC4E5000193049 /* Example */ = { 95 | isa = PBXNativeTarget; 96 | buildConfigurationList = 86F565BB1DFC4E5000193049 /* Build configuration list for PBXNativeTarget "Example" */; 97 | buildPhases = ( 98 | FC88EADFF316DB3605C56CB3 /* [CP] Check Pods Manifest.lock */, 99 | 86F565A51DFC4E5000193049 /* Sources */, 100 | 86F565A61DFC4E5000193049 /* Frameworks */, 101 | 86F565A71DFC4E5000193049 /* Resources */, 102 | 2E5279EE376571B998F7FDC2 /* [CP] Embed Pods Frameworks */, 103 | C18E6D8D7BF6BB92822D96FB /* [CP] Copy Pods Resources */, 104 | ); 105 | buildRules = ( 106 | ); 107 | dependencies = ( 108 | ); 109 | name = Example; 110 | productName = Example; 111 | productReference = 86F565A91DFC4E5000193049 /* Example.app */; 112 | productType = "com.apple.product-type.application"; 113 | }; 114 | /* End PBXNativeTarget section */ 115 | 116 | /* Begin PBXProject section */ 117 | 86F565A11DFC4E5000193049 /* Project object */ = { 118 | isa = PBXProject; 119 | attributes = { 120 | LastSwiftUpdateCheck = 0810; 121 | LastUpgradeCheck = 0810; 122 | ORGANIZATIONNAME = qiuncheng.com; 123 | TargetAttributes = { 124 | 86F565A81DFC4E5000193049 = { 125 | CreatedOnToolsVersion = 8.1; 126 | DevelopmentTeam = 57EP4P69NV; 127 | ProvisioningStyle = Automatic; 128 | }; 129 | }; 130 | }; 131 | buildConfigurationList = 86F565A41DFC4E5000193049 /* Build configuration list for PBXProject "Example" */; 132 | compatibilityVersion = "Xcode 3.2"; 133 | developmentRegion = English; 134 | hasScannedForEncodings = 0; 135 | knownRegions = ( 136 | en, 137 | Base, 138 | ); 139 | mainGroup = 86F565A01DFC4E5000193049; 140 | productRefGroup = 86F565AA1DFC4E5000193049 /* Products */; 141 | projectDirPath = ""; 142 | projectRoot = ""; 143 | targets = ( 144 | 86F565A81DFC4E5000193049 /* Example */, 145 | ); 146 | }; 147 | /* End PBXProject section */ 148 | 149 | /* Begin PBXResourcesBuildPhase section */ 150 | 86F565A71DFC4E5000193049 /* Resources */ = { 151 | isa = PBXResourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | 86F565B71DFC4E5000193049 /* LaunchScreen.storyboard in Resources */, 155 | 86F565B41DFC4E5000193049 /* Assets.xcassets in Resources */, 156 | 86F565B21DFC4E5000193049 /* Main.storyboard in Resources */, 157 | ); 158 | runOnlyForDeploymentPostprocessing = 0; 159 | }; 160 | /* End PBXResourcesBuildPhase section */ 161 | 162 | /* Begin PBXShellScriptBuildPhase section */ 163 | 2E5279EE376571B998F7FDC2 /* [CP] Embed Pods Frameworks */ = { 164 | isa = PBXShellScriptBuildPhase; 165 | buildActionMask = 2147483647; 166 | files = ( 167 | ); 168 | inputPaths = ( 169 | "${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh", 170 | "${BUILT_PRODUCTS_DIR}/NoticeBar/NoticeBar.framework", 171 | ); 172 | name = "[CP] Embed Pods Frameworks"; 173 | outputPaths = ( 174 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NoticeBar.framework", 175 | ); 176 | runOnlyForDeploymentPostprocessing = 0; 177 | shellPath = /bin/sh; 178 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n"; 179 | showEnvVarsInLog = 0; 180 | }; 181 | C18E6D8D7BF6BB92822D96FB /* [CP] Copy Pods Resources */ = { 182 | isa = PBXShellScriptBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | ); 186 | inputPaths = ( 187 | ); 188 | name = "[CP] Copy Pods Resources"; 189 | outputPaths = ( 190 | ); 191 | runOnlyForDeploymentPostprocessing = 0; 192 | shellPath = /bin/sh; 193 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-resources.sh\"\n"; 194 | showEnvVarsInLog = 0; 195 | }; 196 | FC88EADFF316DB3605C56CB3 /* [CP] Check Pods Manifest.lock */ = { 197 | isa = PBXShellScriptBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | ); 201 | inputPaths = ( 202 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 203 | "${PODS_ROOT}/Manifest.lock", 204 | ); 205 | name = "[CP] Check Pods Manifest.lock"; 206 | outputPaths = ( 207 | "$(DERIVED_FILE_DIR)/Pods-Example-checkManifestLockResult.txt", 208 | ); 209 | runOnlyForDeploymentPostprocessing = 0; 210 | shellPath = /bin/sh; 211 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 212 | showEnvVarsInLog = 0; 213 | }; 214 | /* End PBXShellScriptBuildPhase section */ 215 | 216 | /* Begin PBXSourcesBuildPhase section */ 217 | 86F565A51DFC4E5000193049 /* Sources */ = { 218 | isa = PBXSourcesBuildPhase; 219 | buildActionMask = 2147483647; 220 | files = ( 221 | 86F565AF1DFC4E5000193049 /* ViewController.swift in Sources */, 222 | 86F565AD1DFC4E5000193049 /* AppDelegate.swift in Sources */, 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | }; 226 | /* End PBXSourcesBuildPhase section */ 227 | 228 | /* Begin PBXVariantGroup section */ 229 | 86F565B01DFC4E5000193049 /* Main.storyboard */ = { 230 | isa = PBXVariantGroup; 231 | children = ( 232 | 86F565B11DFC4E5000193049 /* Base */, 233 | ); 234 | name = Main.storyboard; 235 | sourceTree = ""; 236 | }; 237 | 86F565B51DFC4E5000193049 /* LaunchScreen.storyboard */ = { 238 | isa = PBXVariantGroup; 239 | children = ( 240 | 86F565B61DFC4E5000193049 /* Base */, 241 | ); 242 | name = LaunchScreen.storyboard; 243 | sourceTree = ""; 244 | }; 245 | /* End PBXVariantGroup section */ 246 | 247 | /* Begin XCBuildConfiguration section */ 248 | 86F565B91DFC4E5000193049 /* Debug */ = { 249 | isa = XCBuildConfiguration; 250 | buildSettings = { 251 | ALWAYS_SEARCH_USER_PATHS = NO; 252 | CLANG_ANALYZER_NONNULL = YES; 253 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 254 | CLANG_CXX_LIBRARY = "libc++"; 255 | CLANG_ENABLE_MODULES = YES; 256 | CLANG_ENABLE_OBJC_ARC = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_CONSTANT_CONVERSION = YES; 259 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 260 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 261 | CLANG_WARN_EMPTY_BODY = YES; 262 | CLANG_WARN_ENUM_CONVERSION = YES; 263 | CLANG_WARN_INFINITE_RECURSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 267 | CLANG_WARN_UNREACHABLE_CODE = YES; 268 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 269 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 270 | COPY_PHASE_STRIP = NO; 271 | DEBUG_INFORMATION_FORMAT = dwarf; 272 | ENABLE_STRICT_OBJC_MSGSEND = YES; 273 | ENABLE_TESTABILITY = YES; 274 | GCC_C_LANGUAGE_STANDARD = gnu99; 275 | GCC_DYNAMIC_NO_PIC = NO; 276 | GCC_NO_COMMON_BLOCKS = YES; 277 | GCC_OPTIMIZATION_LEVEL = 0; 278 | GCC_PREPROCESSOR_DEFINITIONS = ( 279 | "DEBUG=1", 280 | "$(inherited)", 281 | ); 282 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 283 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 284 | GCC_WARN_UNDECLARED_SELECTOR = YES; 285 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 286 | GCC_WARN_UNUSED_FUNCTION = YES; 287 | GCC_WARN_UNUSED_VARIABLE = YES; 288 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 289 | MTL_ENABLE_DEBUG_INFO = YES; 290 | ONLY_ACTIVE_ARCH = YES; 291 | SDKROOT = iphoneos; 292 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 293 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 294 | }; 295 | name = Debug; 296 | }; 297 | 86F565BA1DFC4E5000193049 /* Release */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ALWAYS_SEARCH_USER_PATHS = NO; 301 | CLANG_ANALYZER_NONNULL = YES; 302 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 303 | CLANG_CXX_LIBRARY = "libc++"; 304 | CLANG_ENABLE_MODULES = YES; 305 | CLANG_ENABLE_OBJC_ARC = YES; 306 | CLANG_WARN_BOOL_CONVERSION = YES; 307 | CLANG_WARN_CONSTANT_CONVERSION = YES; 308 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 309 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 310 | CLANG_WARN_EMPTY_BODY = YES; 311 | CLANG_WARN_ENUM_CONVERSION = YES; 312 | CLANG_WARN_INFINITE_RECURSION = YES; 313 | CLANG_WARN_INT_CONVERSION = YES; 314 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 315 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 316 | CLANG_WARN_UNREACHABLE_CODE = YES; 317 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 318 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 319 | COPY_PHASE_STRIP = NO; 320 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 321 | ENABLE_NS_ASSERTIONS = NO; 322 | ENABLE_STRICT_OBJC_MSGSEND = YES; 323 | GCC_C_LANGUAGE_STANDARD = gnu99; 324 | GCC_NO_COMMON_BLOCKS = YES; 325 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 326 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 327 | GCC_WARN_UNDECLARED_SELECTOR = YES; 328 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 329 | GCC_WARN_UNUSED_FUNCTION = YES; 330 | GCC_WARN_UNUSED_VARIABLE = YES; 331 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 332 | MTL_ENABLE_DEBUG_INFO = NO; 333 | SDKROOT = iphoneos; 334 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 335 | VALIDATE_PRODUCT = YES; 336 | }; 337 | name = Release; 338 | }; 339 | 86F565BC1DFC4E5000193049 /* Debug */ = { 340 | isa = XCBuildConfiguration; 341 | baseConfigurationReference = 1E8FDFC944CD379C91E2ABEA /* Pods-Example.debug.xcconfig */; 342 | buildSettings = { 343 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 344 | DEVELOPMENT_TEAM = 57EP4P69NV; 345 | INFOPLIST_FILE = Example/Info.plist; 346 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 347 | PRODUCT_BUNDLE_IDENTIFIER = com.qiuncheng.Example; 348 | PRODUCT_NAME = "$(TARGET_NAME)"; 349 | SWIFT_VERSION = 3.0; 350 | }; 351 | name = Debug; 352 | }; 353 | 86F565BD1DFC4E5000193049 /* Release */ = { 354 | isa = XCBuildConfiguration; 355 | baseConfigurationReference = B6F681E5C7FF564654591910 /* Pods-Example.release.xcconfig */; 356 | buildSettings = { 357 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 358 | DEVELOPMENT_TEAM = 57EP4P69NV; 359 | INFOPLIST_FILE = Example/Info.plist; 360 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 361 | PRODUCT_BUNDLE_IDENTIFIER = com.qiuncheng.Example; 362 | PRODUCT_NAME = "$(TARGET_NAME)"; 363 | SWIFT_VERSION = 3.0; 364 | }; 365 | name = Release; 366 | }; 367 | /* End XCBuildConfiguration section */ 368 | 369 | /* Begin XCConfigurationList section */ 370 | 86F565A41DFC4E5000193049 /* Build configuration list for PBXProject "Example" */ = { 371 | isa = XCConfigurationList; 372 | buildConfigurations = ( 373 | 86F565B91DFC4E5000193049 /* Debug */, 374 | 86F565BA1DFC4E5000193049 /* Release */, 375 | ); 376 | defaultConfigurationIsVisible = 0; 377 | defaultConfigurationName = Release; 378 | }; 379 | 86F565BB1DFC4E5000193049 /* Build configuration list for PBXNativeTarget "Example" */ = { 380 | isa = XCConfigurationList; 381 | buildConfigurations = ( 382 | 86F565BC1DFC4E5000193049 /* Debug */, 383 | 86F565BD1DFC4E5000193049 /* Release */, 384 | ); 385 | defaultConfigurationIsVisible = 0; 386 | defaultConfigurationName = Release; 387 | }; 388 | /* End XCConfigurationList section */ 389 | }; 390 | rootObject = 86F565A11DFC4E5000193049 /* Project object */; 391 | } 392 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Example.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Example 4 | // 5 | // Created by 程庆春 on 2016/12/10. 6 | // Copyright © 2016年 qiuncheng.com. 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 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/notice_bar_example.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "notice_bar_attention@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "notice_bar_attention@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/notice_bar_example.imageset/notice_bar_attention@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Example/Example/Assets.xcassets/notice_bar_example.imageset/notice_bar_attention@2x.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/notice_bar_example.imageset/notice_bar_attention@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Example/Example/Assets.xcassets/notice_bar_example.imageset/notice_bar_attention@3x.png -------------------------------------------------------------------------------- /Example/Example/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 | -------------------------------------------------------------------------------- /Example/Example/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 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 42 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 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 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /Example/Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIViewControllerBasedStatusBarAppearance 6 | 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Example/Example/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Example 4 | // 5 | // Created by 程庆春 on 2016/12/10. 6 | // Copyright © 2016年 qiuncheng.com. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NoticeBar 11 | 12 | class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 13 | 14 | @IBOutlet weak var tableView: UITableView! 15 | lazy var stylesStr: [String] = { 16 | return ["onStatusBar", "onNavigationBar", "onTabbar", "belowStatusBar"] 17 | }() 18 | lazy var animationsTypesStr: [String] = { 19 | return ["top", "bottom", "left", "right"] 20 | }() 21 | 22 | lazy var styles: [NoticeBarStyle] = { 23 | return [.onStatusBar, .onNavigationBar, .onTabbar, .belowStatusBar] 24 | }() 25 | 26 | lazy var animationsTypes: [NoticeBarAnimationType] = { 27 | return [.top, .bottom, .left, .right] 28 | }() 29 | lazy var defaultTypes: [NoticeBarDefaultType] = { 30 | return [.info, .attention, .success, .error] 31 | }() 32 | 33 | override func viewDidLoad() { 34 | super.viewDidLoad() 35 | // Do any additional setup after loading the view, typically from a nib. 36 | self.navigationItem.title = "NoticeBar Example" 37 | } 38 | 39 | override func didReceiveMemoryWarning() { 40 | super.didReceiveMemoryWarning() 41 | // Dispose of any resources that can be recreated. 42 | } 43 | @IBAction func showNoticeBar(_ sender: Any) { 44 | 45 | let noticeBar = NoticeBar(title: "haha", defaultType: .error) 46 | noticeBar.show(duration: 1.8, completed: { 47 | (finished: Bool) in 48 | }) 49 | } 50 | 51 | // MARK: - tableViewDatasource 52 | func numberOfSections(in tableView: UITableView) -> Int { 53 | return stylesStr.count + 1 54 | } 55 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 56 | if (section == stylesStr.count) { 57 | return defaultTypes.count 58 | } 59 | return animationsTypesStr.count 60 | } 61 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 62 | return tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) 63 | } 64 | func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { 65 | if (indexPath.section == stylesStr.count) { 66 | cell.textLabel?.text = defaultTypes[indexPath.row].rawValue 67 | cell.detailTextLabel?.text = "" 68 | } else { 69 | cell.textLabel?.text = stylesStr[indexPath.section] 70 | cell.detailTextLabel?.text = animationsTypesStr[indexPath.row] 71 | } 72 | } 73 | func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 74 | return 10 75 | } 76 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 77 | if (indexPath.section == stylesStr.count) { 78 | let noticeBar = NoticeBar(title: "\(defaultTypes[indexPath.row].rawValue)", defaultType: defaultTypes[indexPath.row]) 79 | noticeBar.show(duration: 2.0, completed: { (finished) in 80 | 81 | }) 82 | } else { 83 | let config = NoticeBarConfig(title: "\(stylesStr[indexPath.section]) with \(animationsTypesStr[indexPath.row]) animation", image: #imageLiteral(resourceName: "notice_bar_example"), textColor: UIColor.white, backgroundColor: UIColor.red, barStyle: styles[indexPath.section], animationType: animationsTypes[indexPath.row]) 84 | let noticeBar = NoticeBar(config: config) 85 | if styles[indexPath.section] != .onTabbar { 86 | UIApplication.shared.statusBarStyle = .lightContent 87 | } 88 | noticeBar.show(duration: 2.0, completed: { 89 | (finished) in 90 | if finished { 91 | UIApplication.shared.statusBarStyle = .default 92 | } 93 | }) 94 | } 95 | } 96 | 97 | } 98 | 99 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '9.0' 2 | 3 | target 'Example' do 4 | use_frameworks! 5 | 6 | pod 'NoticeBar', :path => '../' 7 | end 8 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - NoticeBar (0.1.6) 3 | 4 | DEPENDENCIES: 5 | - NoticeBar (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | NoticeBar: 9 | :path: ../ 10 | 11 | SPEC CHECKSUMS: 12 | NoticeBar: 814717522a50079112c8a6c402efea0dfa6f847f 13 | 14 | PODFILE CHECKSUM: 2e585c257998353a24542a66892e56eead64e0fd 15 | 16 | COCOAPODS: 1.3.1 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 QiunCheng 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 | -------------------------------------------------------------------------------- /NoticeBar.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | 4 | s.name = "NoticeBar" 5 | s.version = "0.1.7" 6 | s.summary = "😍A simple NoticeBar with QQ notice view style.😀" 7 | s.description = <<-DESC 8 | 😍A simple NoticeBar with QQ notice view style.😀 You can use the default style or custom style. 9 | DESC 10 | 11 | s.homepage = "https://github.com/qiuncheng/NoticeBar" 12 | s.license = { :type => "MIT", :file => "LICENSE" } 13 | 14 | s.author = { "Qiuncheng" => "qiuncheng@gmail.com" } 15 | # s.social_media_url = "https://twitter.com/qiuncheng" 16 | 17 | s.platform = :ios, "8.0" 18 | s.source = { :git => "https://github.com/qiuncheng/NoticeBar.git", :tag => s.version } 19 | s.source_files = 'NoticeBar/*.{swift,h}' 20 | s.resource_bundles = {'NoticeBar' => ['NoticeBar/*.xcassets']} 21 | 22 | s.framework = "UIKit" 23 | s.requires_arc = true 24 | 25 | end 26 | -------------------------------------------------------------------------------- /NoticeBar.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 86EFDE8A1DFC1BCA008A11A2 /* NoticeBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EFDE881DFC1BCA008A11A2 /* NoticeBar.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 86EFDE921DFC1BFB008A11A2 /* Bundle+NoticeBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86EFDE901DFC1BFB008A11A2 /* Bundle+NoticeBar.swift */; }; 12 | 86EFDE931DFC1BFB008A11A2 /* NoticeBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86EFDE911DFC1BFB008A11A2 /* NoticeBar.swift */; }; 13 | 86EFDE951DFC1CFE008A11A2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 86EFDE941DFC1CFE008A11A2 /* Images.xcassets */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | 86EFDE851DFC1BCA008A11A2 /* NoticeBar.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NoticeBar.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 18 | 86EFDE881DFC1BCA008A11A2 /* NoticeBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NoticeBar.h; sourceTree = ""; }; 19 | 86EFDE891DFC1BCA008A11A2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 20 | 86EFDE901DFC1BFB008A11A2 /* Bundle+NoticeBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Bundle+NoticeBar.swift"; sourceTree = ""; }; 21 | 86EFDE911DFC1BFB008A11A2 /* NoticeBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoticeBar.swift; sourceTree = ""; }; 22 | 86EFDE941DFC1CFE008A11A2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 23 | /* End PBXFileReference section */ 24 | 25 | /* Begin PBXFrameworksBuildPhase section */ 26 | 86EFDE811DFC1BCA008A11A2 /* Frameworks */ = { 27 | isa = PBXFrameworksBuildPhase; 28 | buildActionMask = 2147483647; 29 | files = ( 30 | ); 31 | runOnlyForDeploymentPostprocessing = 0; 32 | }; 33 | /* End PBXFrameworksBuildPhase section */ 34 | 35 | /* Begin PBXGroup section */ 36 | 86EFDE7B1DFC1BCA008A11A2 = { 37 | isa = PBXGroup; 38 | children = ( 39 | 86EFDE871DFC1BCA008A11A2 /* NoticeBar */, 40 | 86EFDE861DFC1BCA008A11A2 /* Products */, 41 | ); 42 | sourceTree = ""; 43 | }; 44 | 86EFDE861DFC1BCA008A11A2 /* Products */ = { 45 | isa = PBXGroup; 46 | children = ( 47 | 86EFDE851DFC1BCA008A11A2 /* NoticeBar.framework */, 48 | ); 49 | name = Products; 50 | sourceTree = ""; 51 | }; 52 | 86EFDE871DFC1BCA008A11A2 /* NoticeBar */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | 86EFDE901DFC1BFB008A11A2 /* Bundle+NoticeBar.swift */, 56 | 86EFDE911DFC1BFB008A11A2 /* NoticeBar.swift */, 57 | 86EFDE881DFC1BCA008A11A2 /* NoticeBar.h */, 58 | 86EFDE891DFC1BCA008A11A2 /* Info.plist */, 59 | 86EFDE941DFC1CFE008A11A2 /* Images.xcassets */, 60 | ); 61 | path = NoticeBar; 62 | sourceTree = ""; 63 | }; 64 | /* End PBXGroup section */ 65 | 66 | /* Begin PBXHeadersBuildPhase section */ 67 | 86EFDE821DFC1BCA008A11A2 /* Headers */ = { 68 | isa = PBXHeadersBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | 86EFDE8A1DFC1BCA008A11A2 /* NoticeBar.h in Headers */, 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | /* End PBXHeadersBuildPhase section */ 76 | 77 | /* Begin PBXNativeTarget section */ 78 | 86EFDE841DFC1BCA008A11A2 /* NoticeBar */ = { 79 | isa = PBXNativeTarget; 80 | buildConfigurationList = 86EFDE8D1DFC1BCA008A11A2 /* Build configuration list for PBXNativeTarget "NoticeBar" */; 81 | buildPhases = ( 82 | 86EFDE801DFC1BCA008A11A2 /* Sources */, 83 | 86EFDE811DFC1BCA008A11A2 /* Frameworks */, 84 | 86EFDE821DFC1BCA008A11A2 /* Headers */, 85 | 86EFDE831DFC1BCA008A11A2 /* Resources */, 86 | ); 87 | buildRules = ( 88 | ); 89 | dependencies = ( 90 | ); 91 | name = NoticeBar; 92 | productName = NoticeBar; 93 | productReference = 86EFDE851DFC1BCA008A11A2 /* NoticeBar.framework */; 94 | productType = "com.apple.product-type.framework"; 95 | }; 96 | /* End PBXNativeTarget section */ 97 | 98 | /* Begin PBXProject section */ 99 | 86EFDE7C1DFC1BCA008A11A2 /* Project object */ = { 100 | isa = PBXProject; 101 | attributes = { 102 | LastUpgradeCheck = 0900; 103 | ORGANIZATIONNAME = qiuncheng.com; 104 | TargetAttributes = { 105 | 86EFDE841DFC1BCA008A11A2 = { 106 | CreatedOnToolsVersion = 8.1; 107 | LastSwiftMigration = 0900; 108 | ProvisioningStyle = Manual; 109 | }; 110 | }; 111 | }; 112 | buildConfigurationList = 86EFDE7F1DFC1BCA008A11A2 /* Build configuration list for PBXProject "NoticeBar" */; 113 | compatibilityVersion = "Xcode 3.2"; 114 | developmentRegion = English; 115 | hasScannedForEncodings = 0; 116 | knownRegions = ( 117 | en, 118 | ); 119 | mainGroup = 86EFDE7B1DFC1BCA008A11A2; 120 | productRefGroup = 86EFDE861DFC1BCA008A11A2 /* Products */; 121 | projectDirPath = ""; 122 | projectRoot = ""; 123 | targets = ( 124 | 86EFDE841DFC1BCA008A11A2 /* NoticeBar */, 125 | ); 126 | }; 127 | /* End PBXProject section */ 128 | 129 | /* Begin PBXResourcesBuildPhase section */ 130 | 86EFDE831DFC1BCA008A11A2 /* Resources */ = { 131 | isa = PBXResourcesBuildPhase; 132 | buildActionMask = 2147483647; 133 | files = ( 134 | 86EFDE951DFC1CFE008A11A2 /* Images.xcassets in Resources */, 135 | ); 136 | runOnlyForDeploymentPostprocessing = 0; 137 | }; 138 | /* End PBXResourcesBuildPhase section */ 139 | 140 | /* Begin PBXSourcesBuildPhase section */ 141 | 86EFDE801DFC1BCA008A11A2 /* Sources */ = { 142 | isa = PBXSourcesBuildPhase; 143 | buildActionMask = 2147483647; 144 | files = ( 145 | 86EFDE921DFC1BFB008A11A2 /* Bundle+NoticeBar.swift in Sources */, 146 | 86EFDE931DFC1BFB008A11A2 /* NoticeBar.swift in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin XCBuildConfiguration section */ 153 | 86EFDE8B1DFC1BCA008A11A2 /* Debug */ = { 154 | isa = XCBuildConfiguration; 155 | buildSettings = { 156 | ALWAYS_SEARCH_USER_PATHS = NO; 157 | CLANG_ANALYZER_NONNULL = YES; 158 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 159 | CLANG_CXX_LIBRARY = "libc++"; 160 | CLANG_ENABLE_MODULES = YES; 161 | CLANG_ENABLE_OBJC_ARC = YES; 162 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 163 | CLANG_WARN_BOOL_CONVERSION = YES; 164 | CLANG_WARN_COMMA = YES; 165 | CLANG_WARN_CONSTANT_CONVERSION = YES; 166 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 167 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 168 | CLANG_WARN_EMPTY_BODY = YES; 169 | CLANG_WARN_ENUM_CONVERSION = YES; 170 | CLANG_WARN_INFINITE_RECURSION = YES; 171 | CLANG_WARN_INT_CONVERSION = YES; 172 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 173 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 174 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 175 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 176 | CLANG_WARN_STRICT_PROTOTYPES = YES; 177 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 178 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 179 | CLANG_WARN_UNREACHABLE_CODE = YES; 180 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 181 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 182 | COPY_PHASE_STRIP = NO; 183 | CURRENT_PROJECT_VERSION = 1; 184 | DEBUG_INFORMATION_FORMAT = dwarf; 185 | ENABLE_STRICT_OBJC_MSGSEND = YES; 186 | ENABLE_TESTABILITY = YES; 187 | GCC_C_LANGUAGE_STANDARD = gnu99; 188 | GCC_DYNAMIC_NO_PIC = NO; 189 | GCC_NO_COMMON_BLOCKS = YES; 190 | GCC_OPTIMIZATION_LEVEL = 0; 191 | GCC_PREPROCESSOR_DEFINITIONS = ( 192 | "DEBUG=1", 193 | "$(inherited)", 194 | ); 195 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 196 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 197 | GCC_WARN_UNDECLARED_SELECTOR = YES; 198 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 199 | GCC_WARN_UNUSED_FUNCTION = YES; 200 | GCC_WARN_UNUSED_VARIABLE = YES; 201 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 202 | MTL_ENABLE_DEBUG_INFO = YES; 203 | ONLY_ACTIVE_ARCH = YES; 204 | SDKROOT = iphoneos; 205 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 206 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 207 | TARGETED_DEVICE_FAMILY = "1,2"; 208 | VERSIONING_SYSTEM = "apple-generic"; 209 | VERSION_INFO_PREFIX = ""; 210 | }; 211 | name = Debug; 212 | }; 213 | 86EFDE8C1DFC1BCA008A11A2 /* Release */ = { 214 | isa = XCBuildConfiguration; 215 | buildSettings = { 216 | ALWAYS_SEARCH_USER_PATHS = NO; 217 | CLANG_ANALYZER_NONNULL = YES; 218 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 219 | CLANG_CXX_LIBRARY = "libc++"; 220 | CLANG_ENABLE_MODULES = YES; 221 | CLANG_ENABLE_OBJC_ARC = YES; 222 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 223 | CLANG_WARN_BOOL_CONVERSION = YES; 224 | CLANG_WARN_COMMA = YES; 225 | CLANG_WARN_CONSTANT_CONVERSION = YES; 226 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 227 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 228 | CLANG_WARN_EMPTY_BODY = YES; 229 | CLANG_WARN_ENUM_CONVERSION = YES; 230 | CLANG_WARN_INFINITE_RECURSION = YES; 231 | CLANG_WARN_INT_CONVERSION = YES; 232 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 233 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 234 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 235 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 236 | CLANG_WARN_STRICT_PROTOTYPES = YES; 237 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 238 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 239 | CLANG_WARN_UNREACHABLE_CODE = YES; 240 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 241 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 242 | COPY_PHASE_STRIP = NO; 243 | CURRENT_PROJECT_VERSION = 1; 244 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 245 | ENABLE_NS_ASSERTIONS = NO; 246 | ENABLE_STRICT_OBJC_MSGSEND = YES; 247 | GCC_C_LANGUAGE_STANDARD = gnu99; 248 | GCC_NO_COMMON_BLOCKS = YES; 249 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 250 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 251 | GCC_WARN_UNDECLARED_SELECTOR = YES; 252 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 253 | GCC_WARN_UNUSED_FUNCTION = YES; 254 | GCC_WARN_UNUSED_VARIABLE = YES; 255 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 256 | MTL_ENABLE_DEBUG_INFO = NO; 257 | SDKROOT = iphoneos; 258 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 259 | TARGETED_DEVICE_FAMILY = "1,2"; 260 | VALIDATE_PRODUCT = YES; 261 | VERSIONING_SYSTEM = "apple-generic"; 262 | VERSION_INFO_PREFIX = ""; 263 | }; 264 | name = Release; 265 | }; 266 | 86EFDE8E1DFC1BCA008A11A2 /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | CLANG_ENABLE_MODULES = YES; 270 | CODE_SIGN_IDENTITY = ""; 271 | DEFINES_MODULE = YES; 272 | DEVELOPMENT_TEAM = ""; 273 | DYLIB_COMPATIBILITY_VERSION = 1; 274 | DYLIB_CURRENT_VERSION = 1; 275 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 276 | INFOPLIST_FILE = NoticeBar/Info.plist; 277 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 278 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 279 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 280 | PRODUCT_BUNDLE_IDENTIFIER = com.qiuncheng.NoticeBar; 281 | PRODUCT_NAME = "$(TARGET_NAME)"; 282 | SKIP_INSTALL = YES; 283 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 284 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 285 | SWIFT_VERSION = 4.0; 286 | }; 287 | name = Debug; 288 | }; 289 | 86EFDE8F1DFC1BCA008A11A2 /* Release */ = { 290 | isa = XCBuildConfiguration; 291 | buildSettings = { 292 | CLANG_ENABLE_MODULES = YES; 293 | CODE_SIGN_IDENTITY = ""; 294 | DEFINES_MODULE = YES; 295 | DEVELOPMENT_TEAM = ""; 296 | DYLIB_COMPATIBILITY_VERSION = 1; 297 | DYLIB_CURRENT_VERSION = 1; 298 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 299 | INFOPLIST_FILE = NoticeBar/Info.plist; 300 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 301 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 302 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 303 | PRODUCT_BUNDLE_IDENTIFIER = com.qiuncheng.NoticeBar; 304 | PRODUCT_NAME = "$(TARGET_NAME)"; 305 | SKIP_INSTALL = YES; 306 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 307 | SWIFT_VERSION = 4.0; 308 | }; 309 | name = Release; 310 | }; 311 | /* End XCBuildConfiguration section */ 312 | 313 | /* Begin XCConfigurationList section */ 314 | 86EFDE7F1DFC1BCA008A11A2 /* Build configuration list for PBXProject "NoticeBar" */ = { 315 | isa = XCConfigurationList; 316 | buildConfigurations = ( 317 | 86EFDE8B1DFC1BCA008A11A2 /* Debug */, 318 | 86EFDE8C1DFC1BCA008A11A2 /* Release */, 319 | ); 320 | defaultConfigurationIsVisible = 0; 321 | defaultConfigurationName = Release; 322 | }; 323 | 86EFDE8D1DFC1BCA008A11A2 /* Build configuration list for PBXNativeTarget "NoticeBar" */ = { 324 | isa = XCConfigurationList; 325 | buildConfigurations = ( 326 | 86EFDE8E1DFC1BCA008A11A2 /* Debug */, 327 | 86EFDE8F1DFC1BCA008A11A2 /* Release */, 328 | ); 329 | defaultConfigurationIsVisible = 0; 330 | defaultConfigurationName = Release; 331 | }; 332 | /* End XCConfigurationList section */ 333 | }; 334 | rootObject = 86EFDE7C1DFC1BCA008A11A2 /* Project object */; 335 | } 336 | -------------------------------------------------------------------------------- /NoticeBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NoticeBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /NoticeBar.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /NoticeBar.xcodeproj/xcshareddata/xcschemes/NoticeBar.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /NoticeBar/Bundle+NoticeBar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Qiun Cheng on 2016/12/10. 3 | // Copyright © 2016年 http://qiuncheng.com. All rights reserved. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | 15 | import Foundation 16 | 17 | extension Bundle { 18 | /// Create a new Bundle instance for 'Image.xcassets'. 19 | /// 20 | /// - Returns: a new bundle which contains 'Image.xcassets'. 21 | static func currentBundle() -> Bundle { 22 | let bundle = Bundle(for: NoticeBar.self) 23 | if let path = bundle.path(forResource: "NoticeBar", ofType: "bundle") { 24 | return Bundle(path: path)! 25 | } else { 26 | return bundle 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_attention.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "notice_bar_attention@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "notice_bar_attention@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_attention.imageset/notice_bar_attention@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/NoticeBar/Images.xcassets/notice_bar_attention.imageset/notice_bar_attention@2x.png -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_attention.imageset/notice_bar_attention@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/NoticeBar/Images.xcassets/notice_bar_attention.imageset/notice_bar_attention@3x.png -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_error.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "notice_bar_error@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "notice_bar_error@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_error.imageset/notice_bar_error@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/NoticeBar/Images.xcassets/notice_bar_error.imageset/notice_bar_error@2x.png -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_error.imageset/notice_bar_error@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/NoticeBar/Images.xcassets/notice_bar_error.imageset/notice_bar_error@3x.png -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_info.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "notice_bar_info@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "notice_bar_info@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_info.imageset/notice_bar_info@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/NoticeBar/Images.xcassets/notice_bar_info.imageset/notice_bar_info@2x.png -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_info.imageset/notice_bar_info@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/NoticeBar/Images.xcassets/notice_bar_info.imageset/notice_bar_info@3x.png -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_success.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "notice_bar_success@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "notice_bar_success@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_success.imageset/notice_bar_success@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/NoticeBar/Images.xcassets/notice_bar_success.imageset/notice_bar_success@2x.png -------------------------------------------------------------------------------- /NoticeBar/Images.xcassets/notice_bar_success.imageset/notice_bar_success@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/NoticeBar/Images.xcassets/notice_bar_success.imageset/notice_bar_success@3x.png -------------------------------------------------------------------------------- /NoticeBar/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 | FMWK 17 | CFBundleShortVersionString 18 | 0.1.7 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | UIViewControllerBasedStatusBarAppearance 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /NoticeBar/NoticeBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Qiun Cheng on 2016/12/10. 3 | // Copyright © 2016年 http://qiuncheng.com. All rights reserved. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | 15 | #import 16 | 17 | //! Project version number for NoticeBar. 18 | FOUNDATION_EXPORT double NoticeBarVersionNumber; 19 | 20 | //! Project version string for NoticeBar. 21 | FOUNDATION_EXPORT const unsigned char NoticeBarVersionString[]; 22 | 23 | // In this header, you should import all the public headers of your framework using statements like #import 24 | 25 | 26 | -------------------------------------------------------------------------------- /NoticeBar/NoticeBar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Qiun Cheng on 2016/12/10. 3 | // Copyright © 2016年 http://qiuncheng.com. All rights reserved. 4 | // 5 | // MIT License 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | 15 | import UIKit 16 | 17 | /// The default four *NoticeBarType*, you just tell the NoticeBar what message should show, or you can custom your NoticeBar using **NoticeBarConfig**. 18 | /// 19 | public enum NoticeBarDefaultType: String { 20 | /// The default info *NoticeBar*, with a 'notice_bar_info' image and white backgroundColor. 21 | case info = "notice_bar_info" 22 | /// The default *attention* NoticeBar, with a 'notice_bar_attention' image and orange backgroundColor. 23 | case attention = "notice_bar_attention" 24 | /// The default *success* NoticeBar, with a 'notice_bar_success' image and white backgroundColor. 25 | case success = "notice_bar_success" 26 | /// The default *error* NoticeBar, with a 'notice_bar_error' image and 27 | /// 28 | /// UIColor(red: 249.0/255.0, green: 66.0/255.0, blue: 47.0/255.0, alpha: 1.0) backgroundColor. 29 | case error = "notice_bar_error" 30 | } 31 | 32 | extension NoticeBarDefaultType { 33 | fileprivate var image: UIImage? { 34 | return UIImage(named: self.rawValue, in: Bundle.currentBundle(), compatibleWith: nil) 35 | } 36 | fileprivate var defaultConfig: NoticeBarConfig { 37 | 38 | var config: NoticeBarConfig 39 | 40 | switch self { 41 | case .info: 42 | config = NoticeBarConfig(title: nil, image: self.image, textColor: UIColor.black, backgroundColor: UIColor.white, barStyle: NoticeBarStyle.onNavigationBar, animationType: NoticeBarAnimationType.top) 43 | break 44 | case .success: 45 | config = NoticeBarConfig(title: nil, image: self.image, textColor: UIColor.black, backgroundColor: UIColor(white: 1.0, alpha: 1.0), barStyle: NoticeBarStyle.onNavigationBar, animationType: NoticeBarAnimationType.top) 46 | break 47 | case .error: 48 | config = NoticeBarConfig(title: nil, image: self.image, textColor: UIColor.white, backgroundColor: UIColor(red: 249.0/255.0, green: 66.0/255.0, blue: 47.0/255.0, alpha: 1.0), barStyle: NoticeBarStyle.onNavigationBar, animationType: NoticeBarAnimationType.top) 49 | case .attention: 50 | config = NoticeBarConfig(title: nil, image: self.image, textColor: UIColor.white, backgroundColor: UIColor.orange, barStyle: NoticeBarStyle.onNavigationBar, animationType: NoticeBarAnimationType.top) 51 | 52 | } 53 | return config 54 | } 55 | 56 | fileprivate func statusBarStyles(status: UIStatusBarStyle) -> (beigin: UIStatusBarStyle, end: UIStatusBarStyle) { 57 | switch (status, self) { 58 | case (.default, .error): 59 | return (.lightContent, .default) 60 | 61 | case (.default, .info): 62 | return (.default, .default) 63 | 64 | case (.default, .success): 65 | return (.default, .default) 66 | 67 | case (.default, .attention): 68 | return (.lightContent, .default) 69 | 70 | case (.lightContent, .error): 71 | return (.lightContent, .lightContent) 72 | 73 | case (.lightContent, .info): 74 | return (.default, .lightContent) 75 | 76 | case (.lightContent, .success): 77 | return (.default, .lightContent) 78 | 79 | case (.lightContent, .attention): 80 | return (.lightContent, .lightContent) 81 | 82 | default: 83 | return (status, status) 84 | } 85 | } 86 | } 87 | 88 | /// NoticeBar appear with the animation. 89 | /// 90 | /// And there are four different animation type. 91 | /// - top 92 | /// - bottom 93 | /// - left 94 | /// - right 95 | public enum NoticeBarAnimationType { 96 | /// animate from top, but it doesn't work when NoticeBarStyle is `.onTabbar`. 97 | case top 98 | /// animate from bottom, but it doesn't work when NoticeBarStyle is `.onNavigationBar`, '.onStatusBar', `belowStatusBar`. 99 | case bottom 100 | /// animate from left. 101 | case left 102 | /// animate from right. 103 | case right 104 | } 105 | 106 | extension NoticeBarAnimationType { 107 | 108 | fileprivate func noticeBarViewTransform(with frame: CGRect, _ style: NoticeBarStyle) -> CGAffineTransform { 109 | 110 | var transform = CGAffineTransform.identity 111 | 112 | switch (style, self) { 113 | case (.onStatusBar, .top): 114 | transform = CGAffineTransform(translationX: 0, y: -frame.height) 115 | break 116 | case (.belowStatusBar, .top): 117 | transform = CGAffineTransform(translationX: 0, y: -frame.height) 118 | break 119 | case (.onNavigationBar, .top): 120 | transform = CGAffineTransform(translationX: 0, y: -frame.height) 121 | break 122 | case (.onTabbar, .top): 123 | transform = CGAffineTransform(translationX: 0, y: frame.height) 124 | break 125 | case (.onStatusBar, .bottom): 126 | transform = CGAffineTransform(translationX: 0, y: -frame.height) 127 | break 128 | case (.belowStatusBar, .bottom): 129 | transform = CGAffineTransform(translationX: 0, y: -frame.height) 130 | break 131 | case (.onNavigationBar, .bottom): 132 | transform = CGAffineTransform(translationX: 0, y: -frame.height) 133 | break 134 | case (.onTabbar, .bottom): 135 | transform = CGAffineTransform(translationX: 0, y: frame.height) 136 | break 137 | case (.onStatusBar, .left): 138 | transform = CGAffineTransform(translationX: -frame.width, y: 0) 139 | break 140 | case (.belowStatusBar, .left): 141 | transform = CGAffineTransform(translationX: -frame.width, y: 0) 142 | break 143 | case (.onNavigationBar, .left): 144 | transform = CGAffineTransform(translationX: -frame.width, y: 0) 145 | break 146 | case (.onTabbar, .left): 147 | transform = CGAffineTransform(translationX: -frame.width, y: 0) 148 | break 149 | case (.onStatusBar, .right): 150 | transform = CGAffineTransform(translationX: frame.width, y: 0) 151 | break 152 | case (.belowStatusBar, .right): 153 | transform = CGAffineTransform(translationX: frame.width, y: 0) 154 | break 155 | case (.onNavigationBar, .right): 156 | transform = CGAffineTransform(translationX: frame.width, y: 0) 157 | break 158 | case (.onTabbar, .right): 159 | transform = CGAffineTransform(translationX: frame.width, y: 0) 160 | break 161 | } 162 | 163 | return transform 164 | } 165 | } 166 | 167 | /// Where the NoticeBar you want to show. 168 | /// 169 | /// There are four locations you will show the NoticeBar. 170 | /// - onStatusBar 171 | /// - belowStatusBar 172 | /// - onNavigationBar 173 | /// - onTabbar 174 | public enum NoticeBarStyle { 175 | /// On status bar, it will cover status bar content when showing. 176 | case onStatusBar 177 | /// The NoticeBar content will show below status bar content. You should care the UIStatusBarStyle meanwhile. To enable change UIStatusBarStyle, you should set 178 | /// 179 | /// **View controller-based status bar appearance** to **NO** 180 | /// 181 | /// in your application's **info.plist**. 182 | case belowStatusBar 183 | /// On navigation bar, it will cover all the navigation bar and status bar when showing.You should care the UIStatusBarStyle meanwhile. To enable change UIStatusBarStyle, you should set 184 | /// 185 | /// **View controller-based status bar appearance** to **NO** 186 | /// 187 | /// in your application's **info.plist**. 188 | case onNavigationBar 189 | /// On tab bar, it will cover all tab bar, whatever it has UITabbar or not. 190 | case onTabbar 191 | } 192 | 193 | extension NoticeBarStyle { 194 | 195 | fileprivate func noticeBarProperties() -> NoticeBarProperties { 196 | let screenWidth = UIScreen.main.bounds.width 197 | let screenHeight = UIScreen.main.bounds.height 198 | let edgeInsets: UIEdgeInsets 199 | if #available(iOS 11.0, *) { 200 | edgeInsets = UIApplication.shared.keyWindow?.safeAreaInsets ?? UIEdgeInsets.zero 201 | } else { 202 | edgeInsets = UIEdgeInsets.zero 203 | } 204 | 205 | var properties: NoticeBarProperties 206 | switch self { 207 | case .onNavigationBar: 208 | properties = NoticeBarProperties(shadowOffsetY: 3, fontSizeScaleFactor: 0.55, textFont: UIFont.systemFont(ofSize: 18), viewFrame: CGRect(origin: CGPoint.zero, size: CGSize(width: screenWidth, height: 64.0 + edgeInsets.top))) 209 | case .onStatusBar: 210 | properties = NoticeBarProperties(shadowOffsetY: 2, fontSizeScaleFactor: 0.75, textFont: UIFont.systemFont(ofSize: 13), viewFrame: CGRect(origin: CGPoint.zero, size: CGSize(width: screenWidth, height: 20.0 + edgeInsets.top))) 211 | case .onTabbar: 212 | properties = NoticeBarProperties(shadowOffsetY: -3, fontSizeScaleFactor: 0.55,textFont: UIFont.systemFont(ofSize: 17), viewFrame: CGRect(origin: CGPoint(x: 0, y: screenHeight - 49.0 - edgeInsets.bottom), size: CGSize(width: screenWidth, height: 49.0 + edgeInsets.bottom))) 213 | case .belowStatusBar: 214 | properties = NoticeBarProperties(shadowOffsetY: 2, fontSizeScaleFactor: 0.75, textFont: UIFont.systemFont(ofSize: 13), viewFrame: CGRect(origin: CGPoint.zero, size: CGSize(width: screenWidth, height: 40.0 + edgeInsets.top))) 215 | } 216 | 217 | return properties 218 | 219 | } 220 | 221 | fileprivate func noticeBarOriginY(superViewHeight: CGFloat, _ height: CGFloat) -> CGFloat { 222 | var originY: CGFloat = 0 223 | let edgeInsets: UIEdgeInsets 224 | if #available(iOS 11.0, *) { 225 | edgeInsets = UIApplication.shared.keyWindow?.safeAreaInsets ?? UIEdgeInsets.zero 226 | } else { 227 | edgeInsets = UIEdgeInsets.zero 228 | } 229 | switch self { 230 | case .onNavigationBar: 231 | originY = (superViewHeight - height + edgeInsets.top) * 0.5 + 10 232 | case .onStatusBar: 233 | originY = (superViewHeight - height + edgeInsets.top) * 0.5 234 | case .onTabbar: 235 | originY = (superViewHeight - height - edgeInsets.bottom) * 0.5 236 | case .belowStatusBar: 237 | originY = (superViewHeight * 0.5 - height) * 0.5 + superViewHeight * 0.5 238 | } 239 | return originY 240 | } 241 | 242 | fileprivate var beginWindowLevel: UIWindowLevel { 243 | switch self { 244 | case .onStatusBar: 245 | return UIWindowLevelStatusBar + 1 246 | default: 247 | return UIWindowLevelNormal 248 | } 249 | } 250 | 251 | fileprivate var endWindowLevel: UIWindowLevel { 252 | return UIWindowLevelNormal 253 | } 254 | 255 | } 256 | 257 | /// The inner properties which are determined by NoticeBarStyle. 258 | fileprivate struct NoticeBarProperties { 259 | init() { } 260 | var shadowOffsetY: CGFloat = 0 261 | var fontSizeScaleFactor: CGFloat = 0 262 | var textFont = UIFont() 263 | var viewFrame = CGRect.zero 264 | 265 | init(shadowOffsetY: CGFloat, fontSizeScaleFactor: CGFloat, textFont: UIFont, viewFrame: CGRect) { 266 | self.shadowOffsetY = shadowOffsetY 267 | self.fontSizeScaleFactor = fontSizeScaleFactor 268 | self.textFont = textFont 269 | self.viewFrame = viewFrame 270 | } 271 | } 272 | 273 | /// The NoticeBar configuration you provide if you want to custom. 274 | public struct NoticeBarConfig { 275 | /// Create an empty NoticeBarConfig. 276 | public init() { } 277 | 278 | /// The message you want to show, it will be center if image is nil, or in left. 279 | public var title: String? 280 | /// The image you want to show, usually in the left, if it's nil, the title will be center. default is **nil**. 281 | public var image: UIImage? = nil 282 | /// The space between image's left and NoticeBar left, default is **10.0**. 283 | public var margin: CGFloat = 10.0 284 | /// The title's text color, default is **black**. 285 | public var textColor: UIColor = UIColor.black 286 | /// The NoticeBar's background color, default is **white**. 287 | public var backgroundColor = UIColor.white 288 | /// The animation NoticeBar appear, default is **NoticeBarAnimationType.top** from top. 289 | public var animationType = NoticeBarAnimationType.top 290 | /// The bar style of NoticeBar, default is **NoticeBarStyle.onNavigationBar**. 291 | public var barStyle = NoticeBarStyle.onNavigationBar 292 | 293 | /// Create a NoticeBarConfig with full of configs excepted 'margin'. 294 | /// 295 | /// - Parameters: 296 | /// - title: The message you want to show. 297 | /// - image: The image you want to show, or set nil. 298 | /// - textColor: The title's text color. 299 | /// - backgroundColor: The NoticeBar's background color. 300 | /// - barStyle: The bar style of NoticeBar. 301 | /// - animationType: The animation NoticeBar appear. 302 | public init(title: String?, image: UIImage?, textColor: UIColor, backgroundColor: UIColor, barStyle: NoticeBarStyle, animationType: NoticeBarAnimationType) { 303 | self.title = title 304 | self.image = image 305 | self.textColor = textColor 306 | self.backgroundColor = backgroundColor 307 | self.barStyle = barStyle 308 | self.animationType = animationType 309 | } 310 | 311 | /// Create a NoticeBarConfig with title, image, textColor, backgroundColor, barStyle. others is default. 312 | /// 313 | /// - Parameters: 314 | /// - title: The message you want to show. 315 | /// - image: The image you want to show, or set nil. 316 | /// - textColor: The title's text color. 317 | /// - backgroundColor: The NoticeBar's background color. 318 | /// - barStyle: The bar style of NoticeBar. 319 | public init(title: String?, image: UIImage?, textColor: UIColor, backgroundColor: UIColor, barStyle: NoticeBarStyle) { 320 | self.title = title 321 | self.image = image 322 | self.textColor = textColor 323 | self.backgroundColor = backgroundColor 324 | self.barStyle = barStyle 325 | } 326 | 327 | /// Create a NoticeBarConfig with title, textColor, backgroundColor, barStyle. others is default. Especially 'image' will be nil, it means the message will be center with no image. 328 | /// 329 | /// - Parameters: 330 | /// - title: The message you want to show. 331 | /// - textColor: The title's text color. 332 | /// - backgroundColor: The NoticeBar's background color. 333 | /// - barStyle: The bar style of NoticeBar. 334 | public init(title: String?, textColor: UIColor, backgroundColor: UIColor, barStyle: NoticeBarStyle) { 335 | self.title = title 336 | self.textColor = textColor 337 | self.backgroundColor = backgroundColor 338 | self.barStyle = barStyle 339 | } 340 | 341 | /// Create a NoticeBarConfig with title, image, textColor, backgroundColor. others is default. 342 | /// 343 | /// - Parameters: 344 | /// - title: The message you want to show. 345 | /// - image: The image you want to show, or set nil. 346 | /// - textColor: The title's text color. 347 | /// - backgroundColor: The NoticeBar's background color. 348 | public init(title: String?, image: UIImage?, textColor: UIColor, backgroundColor: UIColor) { 349 | self.title = title 350 | self.image = image 351 | self.textColor = textColor 352 | self.backgroundColor = backgroundColor 353 | } 354 | 355 | /// Create a NoticeBarConfig with title, textColor, backgroundColor. others is default. Especially 'image' will be nil, it means the message will be center with no image. 356 | /// 357 | /// - Parameters: 358 | /// - title: The message you want to show. 359 | /// - textColor: The title's text color. 360 | /// - backgroundColor: The NoticeBar's background color. 361 | public init(title: String?, textColor: UIColor, backgroundColor: UIColor) { 362 | self.title = title 363 | self.textColor = textColor 364 | self.backgroundColor = backgroundColor 365 | } 366 | } 367 | 368 | open class NoticeBar: UIView { 369 | 370 | private var config = NoticeBarConfig() 371 | 372 | 373 | /// Return the titleLabel which the message shows. 374 | open var titleLabel: UILabel? { 375 | return _titleLabel 376 | } 377 | 378 | 379 | /// Return the imageView which the image shows. 380 | open var imageView: UIImageView? { 381 | return _imageView 382 | } 383 | 384 | /// The default type. 385 | private var defaultType: NoticeBarDefaultType? 386 | private var _titleLabel: UILabel? 387 | private var _imageView: UIImageView? 388 | 389 | /// Show the notice bar when you finished create a NoticeBar instance. And it will dismiss automatically. 390 | /// 391 | /// Ususlly you can change **UIStatusBarStyle** before notice bar show, and you also set **UIStatusBarStyle** to pre state. 392 | /// 393 | /// - Parameters: 394 | /// - duration: How long the notice bar will stay. it's up to you, then it will dismiss automatically 395 | /// - completed: When notice bar dimissed, what you want to do. Or you can do nothing, just type nil. 396 | public func show(duration: TimeInterval, completed: ((_ finished: Bool) -> Void)?) { 397 | let appStatusBarStyle = UIApplication.shared.statusBarStyle 398 | self.show(duration: duration, willShow: { 399 | [weak self] in 400 | guard let strongSelf = self else { return } 401 | let currentWindowLevel = strongSelf.config.barStyle.beginWindowLevel 402 | UIApplication.shared.keyWindow?.windowLevel = currentWindowLevel 403 | if let type = strongSelf.defaultType { 404 | let currentStatusBarStyle = type.statusBarStyles(status: appStatusBarStyle).beigin 405 | UIApplication.shared.statusBarStyle = currentStatusBarStyle 406 | } 407 | 408 | }, completed: { 409 | [weak self] (finished) in 410 | guard let strongSelf = self else { return } 411 | completed?(finished) 412 | if finished { 413 | let currentWindowLevel = strongSelf.config.barStyle.endWindowLevel 414 | UIApplication.shared.keyWindow?.windowLevel = currentWindowLevel 415 | if let type = strongSelf.defaultType { 416 | let currentStatusBarStyle = type.statusBarStyles(status: appStatusBarStyle).end 417 | UIApplication.shared.statusBarStyle = currentStatusBarStyle 418 | } 419 | } 420 | }) 421 | } 422 | 423 | /// Create a NoticeBar instance with title and one of four default type. 424 | /// 425 | /// - Parameters: 426 | /// - title: The message you want to show, you'd better not type nil. 427 | /// - defaultType: one of four default type. 428 | public convenience init(title: String?, defaultType: NoticeBarDefaultType ) { 429 | 430 | var config = defaultType.defaultConfig 431 | config.title = title 432 | 433 | self.init(config: config) 434 | self.defaultType = defaultType 435 | } 436 | 437 | /// Create a NoticeBar instance with your custom NoticeBarConfig. 438 | /// 439 | /// - Parameter config: custom NoticeBarConfig. 440 | public init(config: NoticeBarConfig) { 441 | super.init(frame: config.barStyle.noticeBarProperties().viewFrame) 442 | self.backgroundColor = config.backgroundColor 443 | 444 | self.config = config 445 | 446 | self.layer.shadowOffset = CGSize(width: 0, height: config.barStyle.noticeBarProperties().shadowOffsetY) 447 | self.layer.shadowColor = UIColor.lightGray.cgColor 448 | self.layer.shadowRadius = 5 449 | self.layer.shadowOpacity = 0.44 450 | 451 | configSubviews() 452 | } 453 | 454 | private override init(frame: CGRect) { 455 | super.init(frame: frame) 456 | } 457 | 458 | public required init?(coder aDecoder: NSCoder) { 459 | fatalError("init(coder:) has not been implemented") 460 | } 461 | 462 | private func configSubviews() { 463 | /// initial label 464 | _titleLabel = UILabel() 465 | _titleLabel?.text = config.title 466 | _titleLabel?.textColor = config.textColor 467 | _titleLabel?.minimumScaleFactor = config.barStyle.noticeBarProperties().fontSizeScaleFactor 468 | _titleLabel?.adjustsFontSizeToFitWidth = true 469 | _titleLabel?.font = config.barStyle.noticeBarProperties().textFont 470 | addSubview(_titleLabel!) 471 | 472 | var titleLabelOriginX: CGFloat = 0 473 | var titleLabelOriginY: CGFloat = 0 474 | var titleLabelHeight: CGFloat = 0 475 | var titleLabelWidth: CGFloat = 0 476 | 477 | if let image = config.image, 478 | config.barStyle != .onStatusBar, 479 | config.barStyle != .belowStatusBar { 480 | 481 | /// initial imageView 482 | _imageView = UIImageView(image: image) 483 | _imageView?.contentMode = .scaleAspectFill 484 | addSubview(_imageView!) 485 | 486 | let imageViewWidth: CGFloat = 25 487 | let imageViewOriginX = config.margin + 10 488 | let imageViewOriginY = config.barStyle.noticeBarOriginY(superViewHeight: frame.height, imageViewWidth) 489 | _imageView?.frame = CGRect(origin: CGPoint(x: imageViewOriginX, y: imageViewOriginY), 490 | size: CGSize(width: imageViewWidth, height: imageViewWidth)) 491 | 492 | titleLabelOriginX = _imageView!.frame.maxX + config.margin 493 | titleLabelOriginY = _imageView!.frame.origin.y 494 | titleLabelHeight = _imageView!.frame.size.height 495 | titleLabelWidth = UIScreen.main.bounds.width - titleLabelOriginX - config.margin 496 | _titleLabel?.textAlignment = NSTextAlignment.left 497 | 498 | } else { 499 | _titleLabel?.textAlignment = NSTextAlignment.center 500 | 501 | titleLabelHeight = 25 502 | titleLabelWidth = UIScreen.main.bounds.width - 2 * config.margin 503 | titleLabelOriginX = config.margin 504 | titleLabelOriginY = config.barStyle.noticeBarOriginY(superViewHeight: frame.height, titleLabelHeight) 505 | } 506 | 507 | _titleLabel?.frame = CGRect(x: titleLabelOriginX, y: titleLabelOriginY, width: titleLabelWidth, height: titleLabelHeight) 508 | } 509 | 510 | private func show(duration: TimeInterval, willShow: () -> Void, completed: ((_ finished: Bool) -> Void)?) { 511 | 512 | if let subviews = UIApplication.shared.keyWindow?.subviews { 513 | for view in subviews { 514 | if view.isKind(of: NoticeBar.self) { 515 | view.removeFromSuperview() 516 | } 517 | } 518 | } 519 | willShow() 520 | 521 | UIApplication.shared.keyWindow?.addSubview(self) 522 | self.transform = config.animationType.noticeBarViewTransform(with: frame, self.config.barStyle) 523 | UIView.animate(withDuration: 0.4, delay: 0.0, usingSpringWithDamping: 0.90, initialSpringVelocity: 0.0, options: UIViewAnimationOptions.curveEaseInOut, animations: { 524 | [weak self] in 525 | guard let strongSelf = self else { return } 526 | strongSelf.transform = CGAffineTransform.identity 527 | }, completion: { 528 | (finished: Bool) in 529 | if (finished) { 530 | let afterQueue = DispatchQueue(label: "com.qiuncheng.NoticeBar") 531 | let delayTime = DispatchTime.now() + duration 532 | afterQueue.asyncAfter(deadline: delayTime, execute: { 533 | DispatchQueue.main.async { 534 | [weak self] in 535 | guard let strongSelf = self else { return } 536 | /// dismiss 537 | UIView.animate(withDuration: 0.4, animations: { 538 | strongSelf.transform = strongSelf.config.animationType.noticeBarViewTransform(with: strongSelf.frame, strongSelf.config.barStyle) 539 | 540 | }, completion: { (finished) in 541 | completed?(finished) 542 | if (finished) { 543 | strongSelf.removeFromSuperview() 544 | } 545 | }) 546 | } 547 | }) 548 | } 549 | }) 550 | } 551 | 552 | } 553 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | NoticeBar 2 | === 3 | 😍A simple NoticeBar written by Swift 3, similar with QQ notice view.😀 4 | [![Build Status](https://travis-ci.org/qiuncheng/NoticeBar.svg?branch=master)](https://travis-ci.org/qiuncheng/NoticeBar) 5 | [![](https://img.shields.io/badge/Swift-3.0-yellowgreen.svg)](https://github.com/qiuncheng/NoticeBar) 6 | [![](https://img.shields.io/badge/support-iOS8-lightgrey.svg)](https://github.com/qiuncheng/NoticeBar) 7 | [![pod version](https://img.shields.io/badge/Pod-v0.1.5-brightgreen.svg)](https://cocoapods.org/pods/NoticeBar) 8 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 9 | [![](https://img.shields.io/badge/platform-iOS-yellow.svg)](https://github.com/qiuncheng/NoticeBar) 10 | [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/qiuncheng/NoticeBar/master/LICENSE) 11 | 12 | #### ScreenShots 13 |

14 | 15 | 16 | 17 |

18 |

19 | 20 | 21 | 22 |

23 | 24 | **Remember: If you want the status bar style change, you must set the `View controller-based status bar appearance` to `NO` in the `info.plist`.** 25 | 26 | Support 27 | === 28 | Swift 3.0 & iOS 8+ 29 | 30 | Installation 31 | === 32 | #### CocoaPods 33 | 1. add `pod 'NoticeBar'` to your Podfile. 34 | 2. Run `pod install` OR `pod update`. 35 | 3. `import Noticebar` 36 | 37 | #### Carthage 38 | 1. Add Noticebar to your Cartfile. e.g., `github "qiuncheng/Noticebar" ~> 0.1.5` 39 | 2. Run `carthage update` 40 | 3. Follow the rest of the [standard Carthage installation](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) instructions to add Noticebar to your project. 41 | 4. `import NoticeBar` 42 | 43 | #### Manually 44 | 1. [Download](https://github.com/qiuncheng/NoticeBar/archive/master.zip) the full file. 45 | 2. Drag the NoticeBar folder to your project. 46 | 47 | Example 48 | === 49 | #### Four Default Types: 50 | + NoticeBarAnimationType.info 51 | + NoticeBarAnimationType.attention 52 | + NoticeBarAnimationType.success 53 | + NoticeBarAnimationType.error 54 | 55 | How to use? For example: -> `NoticeBarAnimationType.info`: 56 | ```Swift 57 | /// title : The message you want to show 58 | /// defaultType : Above four types with different style above. 59 | let noticeBar = NoticeBar(title: "#message", defaultType:.info) 60 | /// duration : How long the noticeBar will stay. And it will dismiss automatically. 61 | /// completed :optional. When the noticeBar dismissed, what you want to do, nothing type nil. 62 | noticeBar.show(duration: #TimeInterval, completed: { (#Bool) in 63 | }) 64 | ``` 65 | #### Custom `NoticeBarConfig` 66 | The NoticeBarConfig will manage the NoticeBar's `title` default is `nil`, `image` if needed, `textColor` default is `UIColor.black`, `backgroundColor` default is `UIColor.white`, `animationType` default is from `NoticeBarAnimationType.top`, `barStyle` default is `NoticeBarStyle.onNavigationBar`, `margin` default is `10.0` which will determine the space between `image` and `title`, the space between `NoticeBar left` and `image`. 67 | How to use? For example: 68 | ``` 69 | /// NoticeBarConfig : There are some other NoticeBarConfig init, it's up to you which to use. 70 | let config = NoticeBarConfig(title: "#message you want to show.", image: #image, textColor: UIColor.white, backgroundColor: UIColor.red, barStyle: NoticeBarStyle.onNavigationBar, animationType: NoticeBarAnimationType.top ) 71 | let noticeBar = NoticeBar(config: config) 72 | /// do something before noticeBar show. 73 | /// such as : UIApplication.shared.statusBarStyle = .lightContent 74 | noticeBar.show(duration: 2.0, completed: { 75 | (finished) in 76 | if finished { 77 | /// do something here. 78 | /// such as : UIApplication.shared.statusBarStyle = .default 79 | } 80 | }) 81 | ``` 82 | TODO 83 | === 84 | - [ ] Add background image 85 | - [ ] Add custom view 86 | - [x] Add custom super view, now is keyWindows. 87 | - [ ] Add dismiss action manually, now dimiss is automatically. 88 | 89 | Thanks 90 | === 91 | 1. [QQ's Notice View](https://itunes.apple.com/cn/app/qq/id444934666?mt=8) which the idea come from. 92 | 93 | 94 | 2. [Pin's Notice View](https://itunes.apple.com/us/app/pin-jian-tie-ban-kuo-zhan/id1039643846?mt=8) which I take example by. 95 | 96 | 97 | LICENCE 98 | === 99 | Under [MIT License](https://github.com/qiuncheng/NoticeBar/blob/master/LICENSE) 100 | 101 | Copyright (c) 2016 QiunCheng. All rights reserved. 102 | 103 | About me 104 | === 105 | A student in Xidian University. [MY RESUME](https://qiuncheng.github.io/resume.html). 106 | If you have a new idea about this project, [Please let me know.](mailto:qiuncheng@gmail.com) OR pull request. 107 | -------------------------------------------------------------------------------- /Screenshots/notice_bar_atttention.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/notice_bar_atttention.jpg -------------------------------------------------------------------------------- /Screenshots/notice_bar_below_status.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/notice_bar_below_status.jpg -------------------------------------------------------------------------------- /Screenshots/notice_bar_error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/notice_bar_error.jpg -------------------------------------------------------------------------------- /Screenshots/notice_bar_info.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/notice_bar_info.jpg -------------------------------------------------------------------------------- /Screenshots/notice_bar_navigationbar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/notice_bar_navigationbar.jpg -------------------------------------------------------------------------------- /Screenshots/notice_bar_statusbar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/notice_bar_statusbar.jpg -------------------------------------------------------------------------------- /Screenshots/notice_bar_success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/notice_bar_success.jpg -------------------------------------------------------------------------------- /Screenshots/notice_bar_tabbar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/notice_bar_tabbar.jpg -------------------------------------------------------------------------------- /Screenshots/pin_notice_view.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/pin_notice_view.jpg -------------------------------------------------------------------------------- /Screenshots/qq_notice_view_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/qq_notice_view_1.jpg -------------------------------------------------------------------------------- /Screenshots/qq_notice_view_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/status302/NoticeBar/aecf641208871ccc1e7050ced2dbda671d31ecbc/Screenshots/qq_notice_view_2.jpg --------------------------------------------------------------------------------