Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'

前端 未结 7 2038
别跟我提以往
别跟我提以往 2020-12-10 00:39

Just updated pods for xcode 9 and I\'m getting the error below for Cosmos.

Type \'NSAttributedStringKey\' (aka \'NSString\') has no member \'

相关标签:
7条回答
  • 2020-12-10 01:07
    let percentOff = NSMutableAttributedString(string: "\(productOff ?? "0")%OFF", 
    attributes: [NSFontAttributeName: UIFont(name: "Montserrat-Regular", 
    size: 13)!,NSForegroundColorAttributeName: UIColor.black,
     NSBackgroundColorAttributeName: UIColor.black])
        lblPriceDetail.attributedText = percentOff
    

    This worked for me in swift 4.2

    0 讨论(0)
  • 2020-12-10 01:12
    let label = UILabel()
    label.font = UIFont.preferredFont(forTextStyle: .subheadline)
    
    0 讨论(0)
  • 2020-12-10 01:21
     attributes: [NSFontAttributeName: label.font]
    

    it's seem okay with swift 3.2 . i fixed with paging menu viewcontroller library.

    0 讨论(0)
  • 2020-12-10 01:23

    Your pod might have a wrong swift version, not the project settings.

    To change the pod swift setting, go in the file navigator (left of the screen) to Pods (blue icon) and select the pod you're having problems with. Then go to build settings and go to Swift Language version. Select Swift 4.

    0 讨论(0)
  • 2020-12-10 01:24

    You must need to update swift version to 4.0 from Xcode.

    Use below step

    1) Choose Your Project from project manager (left top from Xcode)
    2) Choose Build Settings
    3) Search "Swift language"
    4) Change "Swift Language Version " => Swift 4.0

    0 讨论(0)
  • 2020-12-10 01:27

    In My case I replace This Code

    [NSAttributedStringKey.font : font]
    

    by Code Below

    .size(attributes: [NSFontAttributeName : font])
    

    Hope it Helps.

    0 讨论(0)
提交回复
热议问题