Skip to content

Commit

Permalink
change noticeTop api
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlui committed Jul 28, 2015
1 parent 1a34b1b commit e060693
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions SwiftNotice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import Foundation
import UIKit

extension UIViewController {
func noticeTop(text: String) {
SwiftNotice.noticeOnSatusBar(text, autoClear: true)
}
func noticeTop(text: String, autoClear: Bool) {
SwiftNotice.noticeOnSatusBar(text, autoClear: autoClear)
// api changed from v3.3
func noticeTop(text: String, autoClear: Bool = false, autoClearTime: Int = 1) {
SwiftNotice.noticeOnSatusBar(text, autoClear: autoClear, autoClearTime: autoClearTime)
}

// new apis from v3.3
Expand Down Expand Up @@ -70,7 +68,7 @@ class SwiftNotice: NSObject {
windows.removeAll(keepCapacity: false)
}

static func noticeOnSatusBar(text: String, autoClear: Bool) {
static func noticeOnSatusBar(text: String, autoClear: Bool, autoClearTime: Int) {
let frame = UIApplication.sharedApplication().statusBarFrame
let window = UIWindow()
window.backgroundColor = UIColor.clearColor()
Expand All @@ -94,7 +92,7 @@ class SwiftNotice: NSObject {

if autoClear {
let selector = Selector("hideNotice:")
self.performSelector(selector, withObject: window, afterDelay: 1)
self.performSelector(selector, withObject: window, afterDelay: NSTimeInterval(autoClearTime))
}
}
static func wait() {
Expand Down
Binary file not shown.

0 comments on commit e060693

Please sign in to comment.