RecordingOverlay 0.3.2

RecordingOverlay 0.3.2

Thomas Durand维护。



RecordingOverlay

CocoaPods Compatible Carthage compatible

添加一个包含您选择颜色的边框层的UIWindow。非常适合显示活动状态或录制状态。

功能

  • iOS 9 & tvOS 9兼容
  • 在屏幕上添加边框层
  • 与设备边框匹配完美
  • 支持进入、退出和“呼吸”动画
  • 支持任何边框宽度和颜色
  • 允许禁用用户交互(以及可交互的视图白名单)

要求

  • iOS ≥ 9或tvOS ≥ 9
  • Xcode ≥ 10.2
  • Swift Package Manager集成需要Xcode ≥ 11

安装

Swift 包管理器

仅适用于 Xcode 11 及以上版本,将此存储库添加到项目作为 Swift 包。

CocoaPods

在 Podfile 中指定

target 'MyApp' do
pod 'RecordingOverlay'
end

Carthage

在 Cartfile 中指定

github "Dean151/RecordingOverlay"

使用方式

您可以使用静态帮助器实例化一个基本的覆盖层

// Show an overlay for 3s
let overlay = RecordingOverlay.show()
DispatchQueue.main.asyncAfter(deadline: .now + 3) {
    overlay.hide()
}

或者您可能还想更全面地设置一些东西

// If you don't need to make your settings persistents after hiding,
// Store it in a weak variable. The overlay will retain itself while beeing shown.
weak var overlay: RecordingOverlay?

func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    
    let overlay = RecordingOverlay()
    
    // Change the color
    overlay.color = .blue
    
    // And the border size
    overlay.length = 10
    
    // You may also want to disable the default "breathing" animation
    overlay.isAnimated = false
    
    // Then show it on the screen
    overlay.show(animated: animated)
    
    // It's shown, so it's autoretaining itself. The weak property will just be a reference.
    self.overlay = overlay
}

func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)
    
    self.overlay?.hide(animated: animated)
    // overlay is now nil since it's not retained anymore.
}

您也可以完全或部分禁用用户交互

// Disable user interactions, except for one view
overlay.disableInteractions(exceptFor: myViewInteractable)

// Or multiple views. When called multiple times, only the last list of views will be taken into account
overlay.disableInteractions(exceptFor: [view1, view2])

// Either you hide the the overlay to make the user returning the control, or you can enable back the interactions
overlay.enableInteractions()

遇到问题了吗?

请不要犹豫,在 Github 上提交一个问题,或者通过 Fork 后通过 Pull Request 提出更改。