Skip to content

fatal error: value failed to bridge from Swift type to a Objective-C type #10

Open

Description

@JDSX

I get an error when changing the default text attributes, any help on how to change the default text font ?

Activity

  1. hussc commented on Apr 1, 2016

    @hussc

    When you change the default font, try to change the emphasis attributes and the strong attributes..

  2. indragiek commented on Apr 2, 2016

    @indragiek
    Owner

    @JKinGH Please post the code that you're using.

  3. JDSX commented on Apr 7, 2016

    @JDSX
    Author

    I was trying to change the font within the textViewController by passing it a string

        if let font = UIFont(name: "Lato-Thin", size: 26) {
            attributes.defaultAttributes[NSFontAttributeName] = font
        } 
    
  4. hussc commented on Apr 8, 2016

    @hussc

    @JKinGH assuming that you have a bold version of this font with the name "Lato-Bold", you can use:

            if let boldFont = UIFont(name: "Lato-Bold", size: 26) {
                attributes.emphasisAttributes = [NSFontAttributeName: boldFont]
                attributes.strongAttributes = [NSFontAttributeName: boldFont]
            }
    
  5. JDSX commented on Apr 8, 2016

    @JDSX
    Author

    I am able to change the attributes of bold or any other, but for default text which has no style applied I cannot seem to change the font, even system fonts such as Helvetica.

  6. indragiek commented on Apr 23, 2016

    @indragiek
    Owner

    @JKinGH You mentioned that you "get an error" when the font is changed. What is the error? Or does it just not use the font you specify?

  7. indragiek commented on Apr 23, 2016

    @indragiek
    Owner

    Just realized the error is in the title, sorry. Do you know which value it's failing to bridge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions