Reputation: 3038
I am creating an extension of UIFont in Swift that will return a custom font.
import UIKit
extension UIFont {
func museoSansRounded900(size: CGFloat) -> UIFont {
return UIFont(name: "MuseoSansRounded900", size: size)!
}
}
However, when I use the extension self.titleLabel?.font = UIFont.museoSansRounded900(15.0)
Xcode returns an error in design time saying '(CGFloat) -> UIFont' is not convertible to 'UIFont'
Am I doing something wrong? Xcode is actually asking for UIFont as a paramater instead of a CGFloat when I am using the function from the extension.
Upvotes: 2
Views: 310
Reputation: 119031
museoSansRounded900
should be a class method as you're trying to call it directly on the UIFont
class (which makes it basically a constructor).
class func museoSansRounded900(size: CGFloat) -> UIFont ...
Upvotes: 2