okmr-d / DOFavoriteButton

Cute Animated Button written in Swift.
MIT License
3.61k stars 297 forks source link

Take long time to be displayed at UITableViewCell #28

Open yukitoto opened 8 years ago

yukitoto commented 8 years ago

Thanks for greate library. I use DOFavoriteButton to UITableViewCell. And I use autolayout. I change the button image per cell, because each cell have each state.

Then, it takes long time to display the button. Do you have any idea?

this is snnipet of set data to cell.

func setPostData(post: Post) {
        self.post = post

         if post.myLikeCount < 5 {
            likeIconImageView.imageColorOff = UIColor.myPinkColor()
            likeIconImageView.image               = UIImage(named: "fav")
        }
        else {
            likeIconImageView.imageColorOff = UIColor.mySecondaryColor()
            likeIconImageView.image              = UIImage(named: "fav_disabled")
        }
}
rogomantik commented 8 years ago

same problem to me it was even crash I had to edit

public init(frame: CGRect, image: UIImage!) {
        super.init(frame: frame)
        DispatchQueue.main.async {
            self.image = image
            self.createLayers(image)
            self.addTargets()
            self.mDeselect(false)
        } 
    }

    public required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)!
        DispatchQueue.main.async {
            self.createLayers(UIImage())
            self.addTargets()
            self.mDeselect(false)
        }

    }

but I'm still having problems. you only see the animation. the image is not drawn