Swift编写的类似系统提示库

Bursts 是一个类似于系统提示的小框架,目前已经适配了Swift和SwiftUI,如果喜欢的话,那就点一下star ★吧。

burstsgif.gif

功能特征

  • 支持iOS 10+
  • 可用于 UIKit 和 SwiftUI 应用程序
  • 适配正常/暗黑模式
  • 交互式关闭
  • 支持动态字体大小设置
  • 支持显示标题/副标题
  • 支持屏幕顶部或底部显示

安装

  • CocoaPods
use_frameworks!
platform :ios, '10.0'
pop 'Bursts'
复制代码

属性设置

/// 是否是默认
public var isDefault: Bool = true
/// 背景颜色, eg: .white
public var backgroundColor: UIColor = UIColor.white
/// 阴影颜色, eg: .black
public var shadowColor: UIColor = UIColor.black
/// 阴影半径, eg: 25
public var shadowRadius: CGFloat = 25
/// 阴影偏移, eg: zero
public var shadowOffset: CGSize = .zero
/// 阴影透明度, eg: 0.15
public var shadowOpacity: Float = 0.15
/// 光栅化, eg: true
public var shouldRasterize: Bool = true
public var rasterizationScale: CGFloat = UIScreen.main.scale
public var masksToBounds: Bool = false
/// 标题字体颜色, eg: black
public var titleColor: UIColor = .black
/// 副标题字体颜色, eg: darkGray
public var subtitleColor: UIColor = .darkGray
/// 设置圆角,如果该值没有设置,则取min(width, height) * 0.5
public var cornerRadius: CGFloat = 0
复制代码

使用

1.只设置标题

let burst: Burst = "Title Only"
Bursts.show(burst)
// 或者
let burst = Burst(title: "Title Only")
Bursts.show(burst)
复制代码

2.设置标题和副标题

let burst = burst(title: "Title", subtitle: "Subtitle")
Bursts.show(burst)
复制代码

3.设置标题、副标题、显示停留时间

let burst = burst(title: "Title", subtitle: "Subtitle", duration: 5.0)
Bursts.show(burst)
复制代码

4.添加图标

let burst = burst(title: "Title", subtitle: "Subtitle", icon: UIImage(systemName: "star.fill"), duration: 5.0)
Bursts.show(burst)
复制代码

5.外观设置

// 外观设置
var setting = BurstSetting()
setting.isDefault = false
setting.backgroundColor = UIColor(hex: 0x66ccff)
setting.shadowColor = .orange
setting.titleColor = .white
setting.subtitleColor = UIColor(hex: 0xEFEFEF)
//  init Bursts
let burst = Burst(
    title: "Title",
    subtitle: "Subtitle",
    icon: UIImage(systemName: "star.fill"),
    position: .top,
    duration: 2.0,
    setting: setting
)
// Show Bursts
Bursts.show(burst)
复制代码
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享