Flash Back!

Related tags

Camera Flashback
Overview

Flashback - iOS手势返回

iOS Version Language Flashback Version License Platform

效果图

前言

iOS的侧滑手势返回很难用有木有,而且只能从左侧返回,因为不是系统级别,也不是强制使用,还有很多App还不支持,只能羡慕Android的手势返回。为了解决该问题而制作的该库,还是希望苹果有一天能够带来系统级别的手势返回。

Demo

To run the example project, clone the repo, and run pod install from the Example directory first.

Install

Flashback is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Flashback'

Use

  1. 启用(必要)
import Flashback

FlashbackManager.shared.isEnable = true


/// 禁用系统提供的手势返回
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
  1. 可配置
var config = FlashbackConfig.default
// 左右侧启用
config.enablePositions = [.left, .right]
// 触发范围
config.triggerRange = 20
// 震动启用
config.vibrateEnable = true
// 震动强度
config.vibrateStyle = .light
// 指示器样式
config.style = .custom
// 指示器背景颜色
config.backgroundColor = .black
// 指示器图片颜色
config.indicatorColor = .yellow
// 上下滚动开启
config.scrollEnable = true
// 震动启用
config.vibrateEnable = true
// 震动强度
config.vibrateStyle = .light
// 忽略顶部高度(顶部不可侧滑返回)
config.ignoreTopHeight = 150
// ...
FlashbackManager.shared.config = config
  1. 可重写返回逻辑
extension ViewController {
    /// 重写返回
    override func onFlashBack() {
        super.onFlashBack()
    }
}
  1. 可自定义返回栈(页面弹框...)
let alert = AlertView()
alert.show()
// 请注意alert为weak, 否则会因强应用,而导致对象无法释放
FlashbackManager.shared.addFlahback(alert) { [weak alert] in
    guard let `alert` = alert else { return true }
    alert.dismiss()
    return true
}

注意说明

  • 会优先执行返回栈的逻辑,所以如果弹窗后,弹窗不消失,再弹出UIViewController,会出现问题
  • 仅在backModenormal时有效,优先执行返回栈的内容,若targetnil,则会移除顶项,递归继续执行返回,闭包返回为true时执行完移除,为false不移除。
  • 一定要注意target的生命周期,若target产生强应用未被及时释放,则会导致返回出错。若您的target不需要被释放,您可以选择在它消失时手动调用FlashbackManager.shared.backStack.removeLast()
  1. 可通知返回,你可以接管返回逻辑
// 设置返回模式为通知
FlashbackManager.shared.config.backMode = .notify

// 通知回调
NotificationCenter.default.addObserver(forName: FlashbackManager.FlashbackNotificationName, object: nil, queue: nil) { [weak self] _ in
    guard let `self` = self else { return }
    // 执行返回逻辑
    self.navigationController?.popViewController(animated: true)
}

Existing problems

  1. 左右两侧有一部分像素用于了侧滑返回,所以不可点击,可通过修改triggerRange来改变触发范围大小。

Author

可通过邮件的方式联系我: [email protected]

License

Flashback is available under the MIT license. See the LICENSE file for more info.

You might also like...
From JSON to Core Data and back.
From JSON to Core Data and back.

Groot Groot provides a simple way of serializing Core Data object graphs from or into JSON. It uses annotations in the Core Data model to perform the

Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and more…)

Perfect: Server-Side Swift 简体中文 Perfect: Server-Side Swift Perfect is a complete and powerful toolbox, framework, and application server for Linux, iO

Want to know the current weather around the globe? Clima has your back!
Want to know the current weather around the globe? Clima has your back!

Clima (a weather app) Dreaming about going on vacation somewhere? Use Clima to find real time weather from around the world or use your GPS to get loc

CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service.
CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service.

CloudKit, Apple’s remote data storage service, provides a possibility to store app data using users’ iCloud accounts as a back-end storage service. He

Allows trendy transitions using swipe gesture such as
Allows trendy transitions using swipe gesture such as "swipe back anywhere".

SwipeTransition allows trendy transitions using swipe gesture such as "swipe back". Try the demo on the web (appetize.io): https://appetize.io/app/peb

Owner
Lucky_Bking
More Perfect
Lucky_Bking
Starter code for the Flash Chat project in the Complete iOS Development Bootcamp

Flash-Chat Our Goal One of the most fundamental component of modern iOS apps is the Table View. Table Views are used everywhere from the Mail app to t

The App Brewery 45 Jul 30, 2022
An Objective-C wrapper for RocksDB - A Persistent Key-Value Store for Flash and RAM Storage.

ObjectiveRocks ObjectiveRocks is an Objective-C wrapper of Facebook's RocksDB - A Persistent Key-Value Store for Flash and RAM Storage. Current RocksD

Iskandar Abudiab 56 Nov 5, 2022
iOS app to automagically control device torch/flash and capture photos

BlobStar ✨ Version française ???? iOS application to automagically control the device torch/flash and capture photos. The software was quickly drafted

Ninja Inc 1 Oct 11, 2021
Flash-Chat - Firebase Cloud Firestore, TableViews and Cocoapod Dependencies

Flash-Chat Firebase Cloud Firestore, TableViews and Cocoapod Dependencies What I

null 0 Jan 19, 2022
Added Splash Page, App Icon, and Animations when interacting with the flash cards.

flashcards-app Lab 4 App Description Added Splash Page, App Icon, and Animations when interacting with the flash cards. App Walk-though Required User

juan guillermo 1 Apr 12, 2022
Flash Chat is an Internet-based messaging application similar to WhatsApp

Flash Chat is an Internet-based messaging application similar to WhatsApp. A service called Firebase Firestore is used as the backend database to store and retrieve our messages from the cloud.

Matias Adrián Molina 1 May 20, 2022
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and more…)

Perfect: Server-Side Swift 简体中文 Perfect: Server-Side Swift Perfect is a complete and powerful toolbox, framework, and application server for Linux, iO

PerfectlySoft Inc. 13.9k Dec 29, 2022
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and more…)

Perfect: Server-Side Swift 简体中文 Perfect: Server-Side Swift Perfect is a complete and powerful toolbox, framework, and application server for Linux, iO

PerfectlySoft Inc. 13.9k Jan 6, 2023
JSON to Core Data and back. Swift Core Data Sync.

Notice: Sync was supported from it's creation back in 2014 until March 2021 Moving forward I won't be able to support this project since I'm no longer

Nes 2.5k Dec 31, 2022
Powerful property wrapper to back codable properties.

BackedCodable Powerful property wrapper to back codable properties. Why Swift's Codable is a great language feature but easily becomes verbose and req

Jérôme Alves 472 Dec 18, 2022