Surrounding chamber is a small frame similar to the one suggested by the system. Swift and SwiftUI have been adapted now. If you like it, click Star ★.

Functional characteristics

  • Support iOS 10 +
  • Available for UIKit and SwiftUI applications
  • Works in normal/Dark mode
  • Interactive shutdown
  • Support dynamic font size setting
  • Supports display of title/subtitle
  • Supports display at the top or bottom of the screen

The installation

  • CocoaPods
use_frameworks! Platform :ios, '10.0' Pop 'surge'Copy the code

Attribute set

/// Is the default
public var isDefault: Bool = true
/// Background color, eg:.white
public var backgroundColor: UIColor = UIColor.white
/// Shadow color, eg:.black
public var shadowColor: UIColor = UIColor.black
/// Shadow radius, eg: 25
public var shadowRadius: CGFloat = 25
/// Shadow offset, eg: zero
public var shadowOffset: CGSize = .zero
/// Shadow opacity, eg: 0.15
public var shadowOpacity: Float = 0.15
/// rasterize, eg: true
public var shouldRasterize: Bool = true
public var rasterizationScale: CGFloat = UIScreen.main.scale
public var masksToBounds: Bool = false
/// The title font color, eg: black
public var titleColor: UIColor = .black
/// Subtitle font color, eg: darkGray
public var subtitleColor: UIColor = .darkGray
/// Set the rounded corners. If this value is not set, min(width, height) * 0.5
public var cornerRadius: CGFloat = 0
Copy the code

use

1. Set only the title

let burst: Burst = "Title Only"
Bursts.show(burst)
/ / or
let burst = Burst(title: "Title Only")
Bursts.show(burst)
Copy the code

2. Set the title and subtitle

let burst = burst(title: "Title", subtitle: "Subtitle")
Bursts.show(burst)
Copy the code

3. Set the title, subtitle, and display the residence time

let burst = burst(title: "Title", subtitle: "Subtitle", duration: 5.0)
Bursts.show(burst)
Copy the code

4. Add an icon

let burst = burst(title: "Title", subtitle: "Subtitle", icon: UIImage(systemName: "star.fill"), duration: 5.0)
Bursts.show(burst)
Copy the code

5. Appearance Settings

// Appearance Settings
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)
Copy the code