我使用SwiftEntryKit制作和显示自定义消息视图。似乎一切正确,但没有出现消息视图! Xcode版本是:11.3
import UIKit
import SwiftEntryKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .purple
}
@IBAction func btnHandler(_ sender: Any) {
var attributes = EKAttributes()
attributes.displayDuration = .infinity
attributes.position = .bottom
attributes.entryBackground = .gradient(gradient: .init(colors: [UIColor.red, UIColor.green], startPoint: .zero, endPoint: CGPoint(x: 1, y: 1)))
attributes.popBehavior = .animated(animation: .init(translate: .init(duration: 0.3), scale: .init(from: 1, to: 0.7, duration: 0.7)))
attributes.shadow = .active(with: .init(color: .black, opacity: 0.5, radius: 10, offset: .zero))
attributes.statusBar = .dark
attributes.scroll = .enabled(swipeable: true, pullbackAnimation: .jolt)
attributes.positionConstraints.maxSize = .init(width: .constant(value: UIScreen.main.bounds.maxX), height: .intrinsic)
attributes.lifecycleEvents.didAppear = {
print("the view appeared!!!")
}
let title = EKProperty.LabelContent(text: "titleText", style: .init(font: UIFont.systemFont(ofSize: 14), color: UIColor.black))
let description = EKProperty.LabelContent(text: "descText", style: .init(font: UIFont.systemFont(ofSize: 12), color: UIColor.black))
let image = EKProperty.ImageContent(image: UIImage(named: "test")!, size: CGSize(width: 35, height: 35))
let simpleMessage = EKSimpleMessage(image: image, title: title, description: description)
let alertMessage = EKAlertMessage(simpleMessage: simpleMessage, buttonBarContent: .init(with: [EKProperty.ButtonContent(label: .init(text: "test", style: .init(font: UIFont.systemFont(ofSize: 10), color: .black)), backgroundColor: .red, highlightedBackgroundColor: .black)], separatorColor: .black, expandAnimatedly: true))
let alertMessageView = EKAlertMessageView(with: alertMessage)
print("the button was pressed!!!")
SwiftEntryKit.display(entry: alertMessageView, using: attributes)
}
}