Swift 4 Cannot convert value of type '[String : AnyObject]?' to expected argument type '[NSAttributedStringKey : Any]?'

前端 未结 4 2042
悲哀的现实
悲哀的现实 2020-12-19 13:16

I have just updated to Xcode 9 and converted my app from swift 3 to swift 4. I have graphs which use strings to label the axes and other variables. So I have a moneyAxisStri

4条回答
  •  抹茶落季
    2020-12-19 13:53

    Swift 4.2
    Built on example of user_Dennis

     func getCustomStringStyle() -> [NSAttributedString.Key: Any]
        {
            return [
                NSAttributedString.Key(rawValue: NSAttributedString.Key.font.rawValue): UIFont.systemFont(ofSize: 25), // or your fieldFont
                NSAttributedString.Key(rawValue: NSAttributedString.Key.foregroundColor.rawValue): UIColor.black, // or your fieldColor
                NSAttributedString.Key(rawValue: NSAttributedString.Key.paragraphStyle.rawValue): NSParagraphStyle.default // or your style
            ]
        }
    

提交回复
热议问题