Skip to content

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

@KevinQuisquater

Description

@KevinQuisquater

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions