使用 FAPanels 的知名应用
- FanTazTech (https://itunes.apple.com/us/app/fantaztech/id1334853147?mt=8)
- FTT Tech (https://itunes.apple.com/us/app/ftt-tech/id1376054178?mt=8)
- SoleLinks (https://itunes.apple.com/us/app/sole-links/id1434352524?mt=8)
- LOGX (https://itunes.apple.com/us/app/l-o-g-x/id1398600417?mt=8&ign-mpt=uo%3D4)
- RepairDesk (https://itunes.apple.com/pk/app/repairdesk-pos-register/id1246495656?mt=8)
- ScanShake Visitor (https://itunes.apple.com/us/app/scanshake-visitor/id1349888987?mt=8)
- ScanShake Exhibitor (https://itunes.apple.com/us/app/scanshake-exhibitor/id1349889664?mt=8)
新增特性
- 添加了 Swift Package Manager 支持
在拖动时更改中心面板颜色
open var colorForTapView: UIColor = UIColor.black.withAlphaComponent(0.35)
open var shouldAnimateWithPan: Bool = true
已解决的问题(仅限 > 0.5.0)
- XCode 10 支持
- Swift 5.0 支持
已解决的问题(仅限 > 0.4.0)
- 向导视图控制器打开导航栏而将其置于前面时,修正了中心面板的帧变形问题
- 当右侧面板为 nil 并且更新布局面板容器时,已解决崩溃问题
新增功能(仅限 > 0.3.5)
- 在更改中心面板之后立即为侧边栏的任何状态执行完成闭包
- 平滑登出功能(即:当用户在侧边菜单中点击登出按钮或单元格时,您将更改中心面板并可以设置左侧面板为 "nil",因为您不想让用户在登录/注册场景中使用侧菜单)
- 通过平滑中心面板动画更改左侧/右侧菜单
新增功能(仅限 > 0.3.1)
- 仅通过代码创建任意数量的 FAPanelController 实例
- 按您的需求配置其左侧、右侧和中心面板
- 用任意 FAPanelController 对象更新根窗口控制器
用法
// Create FAPanelController object with out any NSCoder, Storyboards and Nib files
let rootController = FAPanelController()
// Configure the panels as you want and assign this panel controller to root controller of window.
window?.rootViewController = rootController
// You can also set window's root controller to any FAPanelController object with different FAPanelConfigurations at any time.
新增功能(仅支持 0.3.0 及以上版本)
- 右侧面板位置(前/后)置于中央面板
- 如果右侧面板位置为前,则右侧面板上添加深色遮罩
右侧面板位置
后 | 前 |
---|---|
使用方法
// Set the Right Panel position
let rootController: FAPanelController = window?.rootViewController as! FAPanelController
rootController.rightPanelPosition = .front
rootController.rightPanelPosition = .back
新增功能(仅支持 0.2.1 及以上版本)
- 左侧面板位置(前/后)置于中央面板
- 如果左侧面板位置为前,则左侧面板上添加阴影
- FAPanel 状态委托功能
左侧面板位置
后 | 前 |
---|---|
使用方法
// Set the Left Panel position
let rootController: FAPanelController = window?.rootViewController as! FAPanelController
rootController.leftPanelPosition = .front
rootController.leftPanelPosition = .back
功能
- 代码实现与.storyboard
- 支持左、右和中央面板
- 更改左侧、右侧或中央面板
- 打开左侧、右侧或中央面板
- 支持动画
- 多面板配置
- 支持所有面板的预置状态栏样式
支持动画过渡
- 从左翻动
- 从右翻动
- 从上翻动
- 从下翻动
- 向上卷曲
- 向下卷曲
- 交叉溶解
- 向上移动
- 向下移动
- 向左移动
- 向右移动
- 水平分割
- 垂直分割
- 倾倒下落
- 方盒淡入淡出
面板配置
// Panels width
var leftPanelWidth : CGFloat = 280 // It will override the gap percentage value
var rightPanelWidth: CGFloat = 280
var leftPanelGapPercentage : CGFloat = 0.8
var rightPanelGapPercentage: CGFloat = 0.8
// resizes all subviews as well
var resizeLeftPanel : Bool = false
var resizeRightPanel: Bool = false
// Adds push animation on side panels
var pusheSidePanels: Bool = false
// Bounce effects on panel animations
var bounceOnLeftPanelOpen : Bool = true
var bounceOnRightPanelOpen : Bool = true
var bounceOnCenterPanelOpen: Bool = true
var bounceOnLeftPanelClose : Bool = false
var bounceOnRightPanelClose : Bool = false
var bounceOnCenterPanelChange: Bool = true
var bouncePercentage : CGFloat = 0.075
var bounceDuration : CGFloat = 0.1
// Panning Gesture
var canRecognizePanGesture: Bool = true
var panFromEdge : Bool = false
var minEdgeForLeftPanel : CGFloat = 70.0
var minEdgeForRightPanel : CGFloat = 70.0
var canLeftSwipe : Bool = true
var canRightSwipe: Bool = true
// restricts panning gesture to work for top VC of Navigation/TabBar Controller
var restrictPanningToTopVC: Bool = true
// Handles the interface auto rotation of visible panel
var handleAutoRotation: Bool = true
// Applies corner radius to panels
var cornerRadius: CGFloat = 0.0
// Shadow configurations
open var shadowColor : CGColor = UIColor.black.cgColor
open var shadowOffset : CGSize = CGSize(width: 10.0, height: 0.0)
open var shadowOppacity: Float = 0.5
// Remove panels from super view when possible
var unloadRightPanel: Bool = false
var unloadLeftPanel : Bool = false
// Max animation duration for animations of side panels
var maxAnimDuration : CGFloat = 0.20
// percentage of screen's width to the centerPanel.view must move for panGesture to succeed
var minMovePercentage: CGFloat = 0.15
// Only Center Panel Change animation
var changeCenterPanelAnimated : Bool = true
var centerPanelTransitionType : FAPanelTransitionType = .crossDissolve
var centerPanelTransitionDuration: TimeInterval = 0.60
安装
CocoaPods
CocoaPods 是一个 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用 CocoaPods 将 FAPanel 集成到您的 Xcode 项目中,请在您的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'FAPanels'
end
然后,运行以下命令
$ pod install
Carthage
Carthage 是一个去中心化的依赖管理器,用于构建您的依赖项并提供二进制框架。
您可以使用 Homebrew 安装 Carthage,命令如下
$ brew update
$ brew install carthage
要使用 Carthage 将 FAPanels 集成到您的 Xcode 项目中,请在您的 Cartfile
中指定它
github "fahidattique55/FAPanels" >= 0.2.0
运行 carthage update
来构建框架,并将构建的 FAPanels.framework
拖入您的 Xcode 项目。
用法
步骤 1
- 将根窗口设置为 FAPanel 控制器,如下图所示,
步骤 2
- 在
AppDelegate.swift
文件中添加以下代码,
// Load the Controllers
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let leftMenuVC: LeftMenuVC = mainStoryboard.instantiateViewController(withIdentifier: "LeftMenuVC") as! LeftMenuVC
let rightMenuVC: RightMenuVC = mainStoryboard.instantiateViewController(withIdentifier: "RightMenuVC") as! RightMenuVC
let centerVC: CenterVC = mainStoryboard.instantiateViewController(withIdentifier: "CenterVC1") as! CenterVC
let centerNavVC = UINavigationController(rootViewController: centerVC)
// Set the Panel controllers with just two lines of code
let rootController: FAPanelController = window?.rootViewController as! FAPanelController
rootController.center(centerNavVC).left(leftMenuVC).right(rightMenuVC)
- 大功告成!运行代码,看看魔法吧。
步骤 2(继续 - 面板控制器)
- 如果不想要设置 RightMenuVC,则只需删除右面板代码。
// This is the code to set all panels
rootController.center(centerNavVC).left(leftMenuVC).right(rightMenuVC)
// Updated code which have only left and center panels
rootController.center(centerNavVC).left(leftMenuVC)
// Similarly, if left panel is not needed the remove the left panel code.
rootController.center(centerNavVC).right(rightMenuVC)
// In case you only want the center panel, then update code to
rootController.center(centerNavVC)
步骤 2(继续 - 面板配置)
- 在设置面板之前配置面板
rootController.configs.rightPanelWidth = 80
rootController.configs.bounceOnRightPanelOpen = false
// Should Pan from edge? Add these lines of code,
rootController.configs.panFromEdge = false
rootController.configs.minEdgeForLeftPanel = 70
rootController.configs.minEdgeForRightPanel = 70
rootController.center(centerNavVC).left(leftMenuVC).right(rightMenuVC)
// For more configurations and their details, Please have a look into ``` FAPanelConfigurations.swift ``` file
访问面板
- 面板可以从任何视图控制器访问
panel?.configs = FAPanelConfigurations()
打开/关闭面板
- 用/不用动画打开或关闭左右面板
panel?.openLeft(animated: true)
panel?.openRight(animated: true)
- 打开/关闭面板预览
更改/删除面板
- 从任何视图控制器更改或删除左侧、右侧或中心面板
// Change Center panel
let centerVC: UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "CenterVC2")
let centerNavVC = UINavigationController(rootViewController: centerVC)
panel!.center(centerNavVC)
// Change Left panel
let leftVC: UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "LeftVC")
panel!.left(leftVC)
// Remove Left panel
panel!.left(nil)
- 预览,当从左侧/右侧面板切换到中央面板时
更改中央面板(带自定义过渡和持续时间)
- 从任何视图控制器更改或删除左侧、右侧或中心面板
// Specify the transition type
panel!.configs.centerPanelTransitionType = .transitionOption // Transitions supported are mentioned in FAPanelTransitionType
// Specify the transition duration
panel!.configs.centerPanelTransitionDuration = 0.60
// Update the center panel
panel!.center(centerNavVC)
- 过渡预览
从左翻转 | 从右翻转 |
---|---|
从上翻转 | 从下翻转 |
---|---|
向上卷曲 | 向下卷曲 |
---|---|
交叉溶解 | 向右移动 |
---|---|
向左移动 | 向上移动 |
---|---|
向下移动 | 垂直分割 |
---|---|
水平分割 | 倾倒下落 |
---|---|
方块淡入 |
---|
支持界面旋转
许可证
FAPanels遵从Apache许可证2.0。
更多详情请访问 https://apache.ac.cn/licenses/LICENSE2.0
作者
Fahid Attique - (https://github.com/fahidattique55)