okmr-d / DOFavoriteButton

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

Converted to Swift 3 syntax #35

Closed ph1ps closed 8 years ago

ph1ps commented 8 years ago

Adressing #31 and #32

kiwo12345 commented 8 years ago

Button doesnt show up for me when using storyboard with this PL

ph1ps commented 8 years ago

@kiwo12345 Hmm can't reproduce... Can you upload your project? bildschirmfoto 2016-10-07 um 08 24 56

kiwo12345 commented 8 years ago

@ph1ps Yeah I tried yours and it didnt work. Though the example works just fine which is strange. But if I add self.layoutIfNeeded() the button will show up but it will also cast a constraint error:

    "<NSLayoutConstraint:0x608000093920 App.DOFavoriteButton:0x7ff542d33fc0.height == 44   (active)>",
    "<NSLayoutConstraint:0x608000093b00 '_UITemporaryLayoutHeight' App.DOFavoriteButton:0x7ff542d33fc0.height == 1000   (active)>"

It almost feels like it wont work if you have alot of views/stuff going on in your VC. I will try to add the button by code and see what happens :)

ph1ps commented 8 years ago

@kiwo12345 Yeah right after your comment I noticed that too. If you change just 1 constraint it breaks. Adding the button by code works but try setting constraints there. Maybe you could tell me your results. I will definitly look into it later. Thanks!

kiwo12345 commented 8 years ago

@ph1ps I could not get it to work by code either :/

I added the button in viewdidload by:


let width = (self.view.frame.width - 44) / 4
        var x = width / 2
        let y = self.view.frame.height / 2 - 22

        let starButton = DOFavoriteButton(frame: CGRect(x: x, y: y, width: 44, height: 44), image: UIImage(named: "table-select.pdf"))
        self.view.addSubview(starButton)

But the button will take up the whole screen:

screen shot 2016-10-07 at 14 22 39
kiwo12345 commented 8 years ago

@ph1ps The same issue using this lib: https://github.com/xhamr/fave-button

ph1ps commented 8 years ago

@kiwo12345 I will close the PR for now, this project seems to be much more broken than I thought.

kiwo12345 commented 8 years ago

@ph1ps Finally found a "fix"!! If you set the constraint priority (on all button constraints) to anything under 1000 it will work using storyboard. Right now I have 6 constraints added to my button once I set their priority to 750 the error didnt show

Edit Set the button height/width constraint to a priority of 750

ph1ps commented 8 years ago

@kiwo12345 Found that too but the the button was all stretched when I tried that...

kiwo12345 commented 8 years ago

@ph1ps did you try to lower the constraint priority when using storyboard? At leats that works for me now. Seems like once you call self.layoutIfNeeded() two constraints gets added while the button is drawn so lowering fixes it