PhilippeBoisney / AlertOnboarding

A simple and attractive AlertView to onboard your users in your amazing world.
MIT License
842 stars 109 forks source link

Broken on iOS 12 (center of alert is in bottom-right corner of device) #31

Open KevinQuisquater opened 6 years ago

KevinQuisquater commented 6 years ago

Thanks Philippe for the pod!

A quick heads-up, the alert is broken on iOS 12 beta.

Since I had to manually install the pod anyway to include all the nice PRs that people have pushed, here's how I replaced the constraints to fix the issue (only tested on iPhone X). Won't be pushing a PR because there is already a list of a few ones waiting, plus I am using a UIView convenience extension to create my anchors in a few lines.

In AlertOnboarding, after removing the constraints (keep those lines), here are the constraints to create:


For anyone using LBTAComponents's UIView extension, here's a ready-to-use snippet to replace AlertOnboarding' configureConstraints function:

fileprivate func configureConstraints(_ superView: UIView) {

    removeConstraints(constraints)
    buttonBottom.removeConstraints(buttonBottom.constraints)
    container.view.removeConstraints(container.view.constraints)

    equal(width: superView.widthAnchor, widthMultiplier: percentageRatioWidth,
          height: superView.heightAnchor, heightMultiplier: percentageRatioHeight)
    anchorCenterSuperview()

    buttonBottom.equal(width: widthAnchor, height: heightAnchor, heightMultiplier: 0.1)
    buttonBottom.anchor(bottom: bottomAnchor)
    buttonBottom.anchorCenterXToSuperview()

    //Constraints for container
    container.view.equal(width: widthAnchor, height: heightAnchor, heightMultiplier: 0.9)
    container.view.anchor(top: topAnchor)
    container.view.anchorCenterXToSuperview()

    //Constraints for background
    background.fillSuperview()
}
alejandroluengo commented 6 years ago

Thanks for the snippet, I am stuck trying to implement this but I have three errors with equal(width... Value of type 'UIButton?' has no member 'equal'

Where this function comes from?

Any help will be much welcome :)

KevinQuisquater commented 6 years ago

Hey Alejandro, might be a method that was not part of LBTAComponents, sorry. Here it is:

public func equal(width: NSLayoutDimension? = nil, widthMultiplier: CGFloat? = 1.0, height: NSLayoutDimension? = nil, heightMultiplier: CGFloat? = 1.0) {
        translatesAutoresizingMaskIntoConstraints = false
        if let width = width {
            widthAnchor.constraint(equalTo: width, multiplier: widthMultiplier!).isActive = true
        }
        if let height = height {
            heightAnchor.constraint(equalTo: height, multiplier: heightMultiplier!).isActive = true
        }
    }
alejandroluengo commented 6 years ago

Implemented and working Kevin

Thank you so much for your help

Best Regards

rubyboy commented 5 years ago

Thanks for providing the workaround! FYI, I found the following fork with this fix and other recent improvements in it: https://github.com/gilthonweapps/AlertOnboarding