AlertOnboarding icon indicating copy to clipboard operation
AlertOnboarding copied to clipboard

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

Open KevinQuisquater opened this issue 7 years ago • 4 comments

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()
}

KevinQuisquater avatar Jul 19 '18 10:07 KevinQuisquater

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 :)

alejandroluengo avatar Aug 13 '18 08:08 alejandroluengo

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
        }
    }

KevinQuisquater avatar Aug 13 '18 10:08 KevinQuisquater

Implemented and working Kevin

Thank you so much for your help

Best Regards

alejandroluengo avatar Aug 14 '18 06:08 alejandroluengo

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

rubyboy avatar Sep 20 '18 12:09 rubyboy