Skip to content

Conversation

@osrl
Copy link

@osrl osrl commented Jan 25, 2015

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)
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant