raspu / Highlightr

iOS & OSX Syntax Highlighter.
MIT License
1.67k stars 262 forks source link

Theme not settings #35

Closed JosephShenton closed 6 years ago

JosephShenton commented 6 years ago

For some reason the theme isn't setting. It's probably really easy but i can't figure it out

heres my code

let layoutManager = NSLayoutManager()
        textStorage.addLayoutManager(layoutManager)

        let textContainer = NSTextContainer(size: view.bounds.size)
        layoutManager.addTextContainer(textContainer)

//        highlightr = textStorage.highlightr

        self.textStorage.highlightr.setTheme(to: "hopscotch")

        textView = UITextView(frame: viewPlaceholder.bounds, textContainer: textContainer)
        textView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
        textView.autocorrectionType = UITextAutocorrectionType.no
        textView.autocapitalizationType = UITextAutocapitalizationType.none
//        textView.textColor = UIColor(white: 0.8, alpha: 1.0)
//        textView.inputAccessoryView = textToolbar
        viewPlaceholder.addSubview(textView)

        let code = try! String.init(contentsOfFile: Bundle.main.path(forResource: "index", ofType: "html")!)
        textView.text = code
raspu commented 6 years ago

Hey @JosephShenton, one quick question, where did you find about out highlightr? I am seeting a lot of traffic, but I have no idea were is coming from.

JosephShenton commented 6 years ago

I found out by Googling "Swift Syntax highlighter github"

raspu commented 6 years ago

Well, that doesn't explain the rest of the people :S ... But, thank you.

steve-taylor commented 6 years ago

@JosephShenton can you please share with us how you resolved this? I have the same problem.

steve-taylor commented 6 years ago

I realised that the theme was indeed working, just that the background color of the UITextView also needed to be set:

textView.backgroundColor = textStorage.highlightr.theme.themeBackgroundColor