我使用这样的默认值结构。
fileprivate struct Defaults {
static var BackgroundColor = UIColor.white
static var TextColor = UIColor.black
static var Title = "Default Title"
static var Message = "Default message!"
static var AnimationDuration: Double = 0.25
static var Duration: Double = 2
static var Height: CGFloat = 90
static var TitleFont: UIFont = UIFont(name: "SourceSansPro-Semibold", size: Defaults.FontSize)!
static var MessageFont: UIFont = UIFont(name: "SourceSansPro-Regular", size: Defaults.FontSize)!
static var FontSize: CGFloat = 14 {
didSet {
TitleFont = TitleFont.withSize(FontSize)
MessageFont = MessageFont.withSize(FontSize)
}
}
}
我有一个方法可以将这些结构值作为默认参数传递。但在 swift4 中它不起作用。
class func showWithAnimation(_ animationType: AnimationType = .basic(timingFunction: CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)),
title: String = Defaults.Title,
message: String = Defaults.Message,
backgroundColor: UIColor = Defaults.BackgroundColor,
textColor: UIColor = Defaults.TextColor,
duration: Double = Defaults.Duration) {
}
请在此处查看总代码。
有什么办法解决这个问题?
谢谢...