微信小程序选项卡功能开发步骤与方法全解析
820
2022-10-28
Aiolos是一个受floating面板启发的Swift UI框架
Aiolos
Yet another iOS Floating Panel
Aiolos, ancient greek for quick-moving/nimble, is a Swift UI framework inspired by the floating panel, that was introduced to Maps app in iOS 11. Give it a try in MindNode 5 for iOS (free trial available).
It is fully gesture-driven, takes safe area insets into account, has support for right-to-left languages baked in and automatically reacts to the on-screen keyboard. Compared to many other open source panel solutions, Aiolos is designed to be an always-visible child view controller, and therefore does not use the custom view controller transition API of iOS.
Integration with Carthage
Add this line to your Cartfile.
github "IdeasOnCanvas/Aiolos"
Usage in Code
There's a demo app, that demonstrates how the Panel can be set up with a different configuration for iPhones and iPads.
func makePanel(with contentViewController: UIViewController) -> Panel { // create Panel with default configuration let configuration = Panel.Configuration.default let panelController = Panel(configuration: configuration) // specify, which ViewController is displayed in the panel panelController.contentViewController = contentViewController // setup delegates that handle size configuration and animation callbacks panelController.sizeDelegate = self panelController.animationDelegate = self // change the configuration to fit you needs panelController.configuration.position = self.panelPosition(for: self.traitCollection) panelController.configuration.margins = self.panelMargins(for: self.traitCollection) panelController.configuration.appearance.separatorColor = .white // we want a different look/behaviour on iPhone compared to iPad if self.traitCollection.userInterfaceIdiom == .pad { panelController.configuration.appearance.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner, .layerMinXMaxYCorner, .layerMaxXMaxYCorner] } else { panelController.configuration.supportedModes = [.minimal, .compact, .expanded, .fullHeight] panelController.configuration.appearance.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] } return panelController}
Configuring the size
extension ViewController: PanelSizeDelegate { func panel(_ panel: Panel, sizeForMode mode: Panel.Configuration.Mode) -> CGSize { let width = self.panelWidth(for: self.traitCollection, position: panel.configuration.position) switch mode { case .minimal: return CGSize(width: width, height: 0.0) case .compact: return CGSize(width: width, height: 64.0) case .expanded: let height: CGFloat = self.traitCollection.userInterfaceIdiom == .phone ? 270.0 : 320.0 return CGSize(width: width, height: height) case .fullHeight: return CGSize(width: width, height: 0.0) } }}
Reacting to Panel animations
extension ViewController: PanelAnimationDelegate { func panel(_ panel: Panel, willTransitionTo size: CGSize) { print("Panel will transition to size \(size)") } func panel(_ panel: Panel, willTransitionFrom oldMode: Panel.Configuration.Mode?, to newMode: Panel.Configuration.Mode, with coordinator: PanelTransitionCoordinator) { print("Panel will transition from \(oldMode) to \(newMode)") // we can animate things along the way coordinator.animateAlongsideTransition({ print("Animating alongside of panel transition") }, completion: { animationPosition in print("Completed panel transition to \(newMode)") }) }}
Credits
Aiolos is brought to you by IdeasOnCanvas GmbH, the creator of MindNode for iOS, macOS & watchOS
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~