iOS开源:NoticeBar - 仿 QQ 与 pin 的消息提示栏,可自定义样式
jjgger1hhx
8年前
<h2>NoticeBar</h2> <p>:heart_eyes: A simple NoticeBar written by Swift 3, similar with QQ notice view. :grinning:</p> <p>ScreenShots</p> <p style="text-align: center;"><img src="https://simg.open-open.com/show/9b37dba00d707f3aadbc52118a69849e.jpg"> <img src="https://simg.open-open.com/show/bf8adfa74c9a211ed9cafad68aae34d7.jpg"> <img src="https://simg.open-open.com/show/929ad0edb8b04d69391e58e1b80bda24.jpg"> <img src="https://simg.open-open.com/show/fa28c8390a8b103235712daa1b8c06b4.jpg"> <img src="https://simg.open-open.com/show/71fc609ff561e0748fe919e114103052.jpg"> <img src="https://simg.open-open.com/show/2d36b7be20282a27cb05f4710eac7694.jpg"> <img src="https://simg.open-open.com/show/d13d1a6254e2ed1fb721366eefe453e6.jpg"> <img src="https://simg.open-open.com/show/29c56484a2ab8f3fb7b39f8e072ded24.jpg"></p> <p>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 .</p> <h2>Support</h2> <p>Swift 3.0 & iOS 8+</p> <h2>Installation</h2> <p>CocoaPods</p> <ol> <li>add pod 'NoticeBar' to your Podfile.</li> <li>Run pod install OR pod update .</li> <li>import Noticebar</li> </ol> <p>Carthage</p> <ol> <li>Add Noticebar to your Cartfile. e.g., github "qiuncheng/Noticebar" ~> 0.1.4</li> <li>Run carthage update</li> <li>Follow the rest of the <a href="/misc/goto?guid=4959635196470755806" rel="nofollow,noindex">standard Carthage installation</a> instructions to add Noticebar to your project.</li> <li>import NoticeBar</li> </ol> <p>Manually</p> <ol> <li>Download the full file.</li> <li>Drag the NoticeBar folder to your project.</li> </ol> <h2>Example</h2> <p>Four Default Types:</p> <ul> <li>NoticeBarAnimationType.info</li> <li>NoticeBarAnimationType.attention</li> <li>NoticeBarAnimationType.success</li> <li>NoticeBarAnimationType.error</li> </ul> <p>How to use? For example: -> NoticeBarAnimationType.info :</p> <pre> /// title : The message you want to show /// defaultType : Above four types with different style above. let noticeBar = NoticeBar(title: "#message", defaultType:.info) /// duration : How long the noticeBar will stay. And it will dismiss automatically. /// completed :optional. When the noticeBar dismissed, what you want to do, nothing type nil. noticeBar.show(duration: #TimeInterval, completed: { (#Bool) in })</pre> <p>Custom NoticeBarConfig</p> <p>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 .</p> <p>How to use? For example:</p> <pre> /// NoticeBarConfig : There are some other NoticeBarConfig init, it's up to you which to use. let config = NoticeBarConfig(title: "#message you want to show.", image: #image, textColor: UIColor.white, backgroundColor: UIColor.red, barStyle: NoticeBarStyle.onNavigationBar, animationType: NoticeBarAnimationType.top ) let noticeBar = NoticeBar(config: config) /// do something before noticeBar show. /// such as : UIApplication.shared.statusBarStyle = .lightContent noticeBar.show(duration: 2.0, completed: { (finished) in if finished { /// do something here. /// such as : UIApplication.shared.statusBarStyle = .default } })</pre> <h2>TODO</h2> <ul> <li>Add background image</li> <li>Add custom view</li> <li>Add custom super view, now is keyWindows.</li> <li>Add dismiss action manually, now dimiss is automatically.</li> </ul> <h2>Thanks</h2> <p>1. <a href="/misc/goto?guid=4959729331528907164" rel="nofollow,noindex">QQ's Notice View</a> which the idea come from.</p> <p style="text-align: center;"><br> <img src="https://simg.open-open.com/show/b641194fea3f2fd4b5154e3830bd8450.jpg"><br> <img src="https://simg.open-open.com/show/a91a89ffa18e90c2bf4de03dd2db2f45.jpg"></p> <p>2. <a href="/misc/goto?guid=4959729331625888683" rel="nofollow,noindex">Pin's Notice View</a> which I take example by.</p> <p style="text-align: center;"><br> <img src="https://simg.open-open.com/show/e29ecdfb9a9aa0b5f471f255b6f98704.jpg"></p> <p> </p> <p> </p> <p> </p>