Skip to content

Commit

Permalink
Added hieght resize on rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
egmoll7 committed Oct 20, 2017
1 parent b364dec commit 034735f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion EMAlertController.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'EMAlertController'
s.version = '1.0.1'
s.version = '1.0.0'
s.summary = 'Elegant alert view controller alternative for iOS'

s.description = <<-DESC
Expand Down
14 changes: 12 additions & 2 deletions EMAlertController/EMAlertController/EMAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import UIKit
// MARK: - EMAlerView Dimensions
enum Dimension {

static let width: CGFloat = 280.0
static var width: CGFloat {
return (UIScreen.main.bounds.width <= 414.0) ? (UIScreen.main.bounds.width - 60) : 280
}
static let padding: CGFloat = 15.0
static let buttonHeight: CGFloat = 50.0
}

open class EMAlertController: UIViewController {

// MARK: - Properties
internal var alertViewHeight: NSLayoutConstraint?
internal var buttonStackViewHeightConstraint: NSLayoutConstraint?
internal var buttonStackViewWidthConstraint: NSLayoutConstraint?
internal var scrollViewHeightConstraint: NSLayoutConstraint?
Expand Down Expand Up @@ -88,6 +91,7 @@ open class EMAlertController: UIViewController {
textview.backgroundColor = UIColor.clear
textview.isScrollEnabled = false
textview.isSelectable = false
textview.bounces = false

return textview
}()
Expand Down Expand Up @@ -221,6 +225,11 @@ open class EMAlertController: UIViewController {
}, completion: nil)
}

open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {

alertViewHeight?.constant = size.height - 80
alertView.layoutIfNeeded()
}
}

// MARK: - Setup Methods
Expand Down Expand Up @@ -257,7 +266,8 @@ extension EMAlertController {
alertView.centerYAnchor.constraint(equalTo: backgroundView.centerYAnchor, constant: 100).isActive = true
alertView.centerXAnchor.constraint(equalTo: backgroundView.centerXAnchor).isActive = true
alertView.widthAnchor.constraint(equalToConstant: Dimension.width).isActive = true
alertView.heightAnchor.constraint(lessThanOrEqualToConstant: view.frame.height - 80).isActive = true
alertViewHeight = alertView.heightAnchor.constraint(lessThanOrEqualToConstant: view.bounds.height - 80)
alertViewHeight!.isActive = true

// imageView Constraints
imageView.topAnchor.constraint(equalTo: alertView.topAnchor, constant: 5).isActive = true
Expand Down

0 comments on commit 034735f

Please sign in to comment.