AttributedMarkdown icon indicating copy to clipboard operation
AttributedMarkdown copied to clipboard

Image Support

Open osrl opened this issue 10 years ago • 0 comments

I'm sure this is not the perfect way to do this. Maybe a block mechanism should be implemented. But this works too. No offence taken if you don't merge this. Maybe someone use it

Added a NSTextAttachment+Image category to load images async. It throws posts a notification named imageLoadedNotification every time an image is loaded

catch this notification with NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("imageLoaded"), name: "imageLoadedNotification", object: nil)

Add this function so it draws the label everytime an image is loaded.

func imageLoaded() {
    self.label.setNeedsDisplay()
    self.label.setNeedsUpdateConstraints()
}

Don't forget to remove observer:

deinit {
    NSNotificationCenter.defaultCenter().removeObserver(self)
}

osrl avatar Jan 25 '15 20:01 osrl