okmr-d / DOFavoriteButton

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

Updated project for Swift 3 #30

Closed AurelTyson closed 7 years ago

AurelTyson commented 8 years ago

I have just updated the project to be compatible with Swift 3.0.

Just create a new branch to continue supporting the current version of Swift.

Thanks !

XHotSniperX commented 8 years ago

Nice, looking forward to try this in Swift 3.0. I just replaced the content of the DOFavoriteButton.swift file with yours and I don't have any compiling errors any more but while running the app the buttons are not visible. They work but they aren't visible. I created the buttons through storyboard as described here. Do you know what could cause this problem?

familyconnect commented 8 years ago

@XHotSniperX add self.layoutIfNeeded() before access frames does the work. I just add at the start of fun fileprivate func createLayers(image: UIImage!). it is needed since upgrade to Xcode 8. If anybody has a more elegant way to achieve this kind if problem?

XHotSniperX commented 8 years ago

@familyconnect that fixed it, thank you!

devJoshLopez commented 8 years ago

anyone know when this will be available on the main branch? im new to github.

AurelTyson commented 8 years ago

Hi, After a quick look I can reproduce the issue but I couldn't resolve it quickly. I will take a look at this weekend ;)

kiwo12345 commented 8 years ago

@familyconnect I also add my buttons using storyboard but if I add your fix I get a constraint error: @AurelTyson did you find anything?

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

@XHotSniperX Dont you get constraint errors with that fix? I get:

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

Dunno why but its adding a 1000H 1000W constraint

kiwo12345 commented 8 years ago

To anyone adding self.layoutIfNeeded() in fileprivate func createLayers(image: UIImage!) in order to get it to work in storyboard will prob get a _UITemporaryLayoutHeight constraint error.

The fix to this is to set the constraints priority to 750 (Anythinig under 1000) on all of your button constraints in storyboard W/H

@XHotSniperX @AurelTyson @familyconnect

kiwo12345 commented 8 years ago

@XHotSniperX @AurelTyson @familyconnect

The constraint issue seems to be fixed in Xcode 8.1 I dont see the error occur if I build the project in xcode 8 and run on a device using ios 10.0