NoticeBar 0.1.7

NoticeBar 0.1.7

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布日期上次发布2017年9月
Swift版本Swift版本3.0
SPM支持SPM

qiuncheng 维护。



NoticeBar 0.1.7

  • Qiuncheng

NoticeBar

😍由Swift 3编写的简单NoticeBar,类似于QQ通知视图。😀

屏幕截图

注意:如果要让状态栏风格发生变化,必须在 info.plist 中将 View controller-based status bar appearance 设置为 NO

支持

Swift 3.0 & iOS 8+

安装

手动

  1. 下载 完整文件。
  2. 将 NoticeBar 文件夹拖到您的项目中。

示例

四种默认类型

  • NoticeBarAnimationType.info
  • NoticeBarAnimationType.attention
  • NoticeBarAnimationType.success
  • NoticeBarAnimationType.error

如何使用?例如:-> NoticeBarAnimationType.info

/// 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
})

自定义 NoticeBarConfig

NoticeBarConfig 会管理 NoticeBar 的 title,默认为 nil,需要时 image,默认文本颜色为 UIColor.black,默认背景颜色为 UIColor.whiteanimationType 默认从 NoticeBarAnimationType.top 开始,barStyle 默认为 NoticeBarStyle.onNavigationBarmargin 默认为 10.0,这将决定 imagetitle 之间的空间,以及 NoticeBar 左侧和 image 之间的空间。
如何使用?例如

/// 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
    }
})

待办事项

  • [ ] 添加背景图片
  • [ ] 添加自定义视图
  • [ ] 添加自定义 super 视图,现在为 keyWindows。
  • [ ] 手动添加 dismiss 操作,现在 dismiss 是自动的。

感谢

  1. QQ的通知视图,该灵感来源于此。

  2. Pin的通知视图,我以此为样本。

许可

MIT 许可证 下。

版权所有 © 2016 QiunCheng. 保留所有权利。

关于我

西电大学的一名学生。我的简历
如果你对这个项目有新的想法,随时联系我! 或者 pull request。