Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KevinQuisquater opened this issue Jul 19, 2018 · 4 comments

Comments

@KevinQuisquater
Copy link

KevinQuisquater commented Jul 19, 2018

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:


  • view width anchored to its superview width, multiplier = percentageRatioWidth
  • view height anchored to its superview height, multiplier = percentageRatioHeight
  • view centered in its superview, on X and Y axis

  • buttomButton width anchored to view width, multiplier 1
  • buttomButton height anchored to view height, multiplier 0.1
  • buttomButton's bottom anchored to view bottom
  • buttomButton centered in its superview on X axis

  • container's view width anchored to view width, multiplier 1
  • container's view height anchored to view height, multiplier 0.9
  • container's view top anchored to view top
  • container's view centered in its superview on X axis

  • background fills its superview (pinned to all edges)

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
Copy link

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
Copy link
Author

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
Copy link

Implemented and working Kevin

Thank you so much for your help

Best Regards

@rubyboy
Copy link

rubyboy commented Sep 20, 2018

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

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

No branches or pull requests

3 participants