I have a custom UITextfield in swift called COSTextField. It is something like
class COSTextField: UITextField {
func customFont() -> UIFont? {
if let font = self.font {
return UIFont(name: kCOSFontRegular, size: font.pointSize)
}
}
}
I am trying to extend this COSTextField class and override the customFont method. My new class looks like
class COSTextFieldLight: COSTextField {
override func customFont() -> UIFont? {
if let font = self.font {
return UIFont(name: kCOSFontLight, size: font.pointSize)
}
}
}
When I try to compile this, I get an error Missing return in a function expected to return 'UIFont?'
. If I add a return nil statement at the end of my override function, I get an error Non-void function should return a value
What am I doing wrong?