UIPopoverCard 1.2.4

UIPopoverCard 1.2.4

Aleksey Pleshkov维护。



UIPopoverCard

UIPopoverCard是一个根据状态或内容自适应的弹出卡片

Screenshot

安装

CocoaPods 是Cocoa项目的依赖管理器。您可以使用以下命令安装它

$ gem install cocoapods

要使用CocoaPods将UIPopoverCard集成到您的Xcode项目中,请在您的Podfile中指定它

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
pod 'UIPopoverCard', '~> 1.2.4'
end

然后,运行以下命令

$ pod install

如何使用

您需要创建一个名为UIPopoverCard的类,并向其中添加UIPopoverCardConfigurationUIPopoverCardBody。在您的ViewController中将代理添加到UIPopoverCardDelegate以便处理事件。

// ...

override func viewDidLoad() {
    super.viewDidLoad()
    // ...
    
    // UIPopoverCard
    let config = UIPopoverCardConfiguration()
    let body = UIPopoverCardBody(xibName: "Test")
    let popoverCard = UIPopoverCard(self, configure: config, body: body)
    
    popoverCard.show()
    // popoverCard.hide()
    
    // ...
}

UIPopoverCardConfiguration参数

let config = UIPopoverCardConfiguration()

config.overlayColor = UIColor.lightGray
config.overlayAlpha = 0.5
config.cardBackgroundColor = UIColor.white
config.headerCardHeight = 20
config.headerCardLineColor = UIColor.lightGray
config.isShowBackground = true
config.isHideCardTapToBackground = true
config.visibleAnimationDuration = 0.35
config.changeStateAnimationDuration = 0.5
config.availableStates = [.small, .middle, .large]
config.isAdaptiveByContent = false
config.isShowHeader = false
config.isChangeSizeBySwipe = true

UIPopoverCardBody 初始化类型

// Create body by ViewController
let body = UIPopoverCardBody(viewController: YOU_UIVIEWCONTROLLER)

// Create body by View
let body = UIPopoverCardBody(view: YOU_UIVIEW)

// Create body from XIB name
let body = UIPopoverCardBody(xibName: "YOU_XIB_NAME")

UIPopoverCardDelegate 事件

/// Will change visibility state of popover card
func popoverCard(_ popoverCard: UIPopoverCard, willChangeShow isVisible: Bool)

/// Did change visibility state of popover card
func popoverCard(_ popoverCard: UIPopoverCard, didChangeShow isVisible: Bool)

/// Did change state of size card
func popoverCard(_ popoverCard: UIPopoverCard, didChangeSize state: UIPopoverCardState)

关于我

许可证

UIPopoverCard 采用 MIT 许可协议发布。简而言之,它是免费的,但你必须保留代码或软件分发中的版权声明。