Skip to content

Commit

Permalink
Merge pull request juanpablofernandez#20 from mpatzer/master
Browse files Browse the repository at this point in the history
Updated overlay layout constraints to use layoutMarginsGuide.
  • Loading branch information
juanpablofernandez authored Dec 7, 2017
2 parents 5f4ebd9 + b6c1620 commit 21b46a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions SwiftyOnboard/SwiftyOnboardOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,27 @@ open class SwiftyOnboardOverlay: UIView {

func setUp() {
self.addSubview(pageControl)

let margin = self.layoutMarginsGuide
pageControl.translatesAutoresizingMaskIntoConstraints = false
pageControl.heightAnchor.constraint(equalToConstant: 15).isActive = true
pageControl.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -10).isActive = true
pageControl.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 10).isActive = true
pageControl.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -10).isActive = true
pageControl.bottomAnchor.constraint(equalTo: margin.bottomAnchor, constant: -10).isActive = true
pageControl.leftAnchor.constraint(equalTo: margin.leftAnchor, constant: 10).isActive = true
pageControl.rightAnchor.constraint(equalTo: margin.rightAnchor, constant: -10).isActive = true

self.addSubview(continueButton)
continueButton.translatesAutoresizingMaskIntoConstraints = false
continueButton.heightAnchor.constraint(equalToConstant: 20).isActive = true
continueButton.bottomAnchor.constraint(equalTo: pageControl.topAnchor, constant: -20).isActive = true
continueButton.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 10).isActive = true
continueButton.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -10).isActive = true
continueButton.leftAnchor.constraint(equalTo: margin.leftAnchor, constant: 10).isActive = true
continueButton.rightAnchor.constraint(equalTo: margin.rightAnchor, constant: -10).isActive = true

self.addSubview(skipButton)
skipButton.translatesAutoresizingMaskIntoConstraints = false
skipButton.heightAnchor.constraint(equalToConstant: 20).isActive = true
skipButton.topAnchor.constraint(equalTo: self.topAnchor, constant: 40).isActive = true
skipButton.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 10).isActive = true
skipButton.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -20).isActive = true
skipButton.topAnchor.constraint(equalTo: margin.topAnchor, constant: 10).isActive = true
skipButton.leftAnchor.constraint(equalTo: margin.leftAnchor, constant: 10).isActive = true
skipButton.rightAnchor.constraint(equalTo: margin.rightAnchor, constant: -20).isActive = true
}

}
18 changes: 10 additions & 8 deletions SwiftyOnboard/SwiftyOnboardPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,25 @@ open class SwiftyOnboardPage: UIView {

func setUp() {
self.addSubview(imageView)

let margin = self.layoutMarginsGuide
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 30).isActive = true
imageView.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -30).isActive = true
imageView.topAnchor.constraint(equalTo: self.topAnchor, constant: 10).isActive = true
imageView.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 0.5).isActive = true
imageView.leftAnchor.constraint(equalTo: margin.leftAnchor, constant: 30).isActive = true
imageView.rightAnchor.constraint(equalTo: margin.rightAnchor, constant: -30).isActive = true
imageView.topAnchor.constraint(equalTo: margin.topAnchor, constant: 10).isActive = true
imageView.heightAnchor.constraint(equalTo: margin.heightAnchor, multiplier: 0.5).isActive = true

self.addSubview(title)
title.translatesAutoresizingMaskIntoConstraints = false
title.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 30).isActive = true
title.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -30).isActive = true
title.leftAnchor.constraint(equalTo: margin.leftAnchor, constant: 30).isActive = true
title.rightAnchor.constraint(equalTo: margin.rightAnchor, constant: -30).isActive = true
title.topAnchor.constraint(equalTo: imageView.bottomAnchor, constant: 10).isActive = true
title.heightAnchor.constraint(equalToConstant: 50).isActive = true

self.addSubview(subTitle)
subTitle.translatesAutoresizingMaskIntoConstraints = false
subTitle.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 30).isActive = true
subTitle.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -30).isActive = true
subTitle.leftAnchor.constraint(equalTo: margin.leftAnchor, constant: 30).isActive = true
subTitle.rightAnchor.constraint(equalTo: margin.rightAnchor, constant: -30).isActive = true
subTitle.topAnchor.constraint(equalTo: title.bottomAnchor, constant: 0).isActive = true
subTitle.heightAnchor.constraint(equalToConstant: 100).isActive = true
}
Expand Down

0 comments on commit 21b46a1

Please sign in to comment.