SCLAlertView-Swift
SCLAlertView-Swift copied to clipboard
Cannot invoke value of type 'SCLAlertView.SCLAppearance.Type' with argument list
I just migrated from Swift 2.3 to Swift 3, and this is the error that I encounter:
Cannot invoke value of type 'SCLAlertView.SCLAppearance.Type' with argument list '(kWindowWidth: CGFloat, showCircularIcon: Bool, kCircleHeight: Int, kCircleIconHeight: CGFloat, kTitleTop: CGFloat, kTitleFont: UIFont, kTextHeight: Int, kTextFont: UIFont, kButtonFont: UIFont)’
I modify just some of the arguments in SCLAppearance as:
let appearance = SCLAlertView.SCLAppearance(
kWindowWidth: width - 64,
showCircularIcon: true,
kCircleHeight: 0,
kCircleIconHeight: width / 2,
kTitleTop: width / 3.5,
kTitleFont: UIFont(name: "ProximaNova-Bold", size: 20)!,
kTextHeight: 50,
kTextFont: UIFont(name: "ProximaNova-Regular", size: 14)!,
kButtonFont: UIFont(name: "ProximaNova-Regular", size: 12)!
)
Do I have to fill all the arguments? And if so, how can I set the default values for the arguments I don’t want to change?
I dealt with this in Swift 3 by passing arguments in ORDER as:
SCLAlertView.SCLAppearance(kDefaultShadowOpacity: <#T##CGFloat#>, kCircleTopPosition: <#T##CGFloat#>, kCircleBackgroundTopPosition: <#T##CGFloat#>, kCircleHeight: <#T##CGFloat#>, kCircleIconHeight: <#T##CGFloat#>, kTitleTop: <#T##CGFloat#>, kTitleHeight: <#T##CGFloat#>, kWindowWidth: <#T##CGFloat#>, kWindowHeight: <#T##CGFloat#>, kTextHeight: <#T##CGFloat#>, kTextFieldHeight: <#T##CGFloat#>, kTextViewdHeight: <#T##CGFloat#>, kButtonHeight: <#T##CGFloat#>, kTitleFont: <#T##UIFont#>, kTextFont: <#T##UIFont#>, kButtonFont: <#T##UIFont#>, showCloseButton: <#T##Bool#>, showCircularIcon: <#T##Bool#>, shouldAutoDismiss: <#T##Bool#>, contentViewCornerRadius: <#T##CGFloat#>, fieldCornerRadius: <#T##CGFloat#>, buttonCornerRadius: <#T##CGFloat#>, hideWhenBackgroundViewIsTapped: <#T##Bool#>, contentViewColor: <#T##UIColor#>, contentViewBorderColor: <#T##UIColor#>, titleColor: <#T##UIColor#>)
This works also when only some of the arguments must be changed and not all.
@waseefakhtar I don't get it, How to just leave the values at default if we do not want to change all?
This will be used in initialization function, so you should keep orders like this.
let appearance = SCLAlertView.SCLAppearance(
kCircleHeight: 0,
kCircleIconHeight: width / 2,
kTitleTop: width / 3.5,
kWindowWidth: width - 64,
kTextHeight: 50,
kTitleFont: UIFont(name: "ProximaNova-Bold", size: 20)!,
kTextFont: UIFont(name: "ProximaNova-Regular", size: 14)!,
kButtonFont: UIFont(name: "ProximaNova-Regular", size: 12)!,
showCircularIcon: true
)
I suggest you to check initializer of SCLAlertView.