Skip to content

Commit d2d33f9

Browse files
committed
Release 1.1.0 with small screens support
1 parent 9bc67de commit d2d33f9

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

AABlurAlertController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "AABlurAlertController"
3-
s.version = "1.0.2"
3+
s.version = "1.1.0"
44
s.summary = "Beautiful configurable Alert View with blurred background"
55

66
s.homepage = "https://github.com/anas10/AABlurAlertController"

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Change Log
2+
3+
## [Unreleased]
4+
5+
## [1.1.0](https://github.com/anas10/AABlurAlertController/tree/1.1.0) (2017-01-20)
6+
### Added
7+
- CHANGELOG
8+
- Clean subviews on setup
9+
- Support for Small screens
10+
11+
## [1.0.2](https://github.com/anas10/AABlurAlertController/tree/1.0.2) (2017-01-20)
12+
### Added
13+
- Missing public for init
14+
15+
## [1.0.1](https://github.com/anas10/AABlurAlertController/tree/1.0.1) (2017-01-20)
16+
### Added
17+
- Missing open for addAction
18+
19+
## [1.0.0](https://github.com/anas10/AABlurAlertController/tree/1.0.0) (2017-01-20)
20+
### Added
21+
- Initial version of the aablurcontroller

Source/AABlurAlertController.swift

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ open class AABlurAlertController: UIViewController {
5959

6060
open var blurEffectStyle: UIBlurEffectStyle = .light
6161
open var imageHeight: Float = 175
62+
open var alertViewWidth: Float?
63+
64+
/**
65+
Set the max alert view width
66+
If you don't want to have a max width set this to nil.
67+
It will take 70% of the superview width by default
68+
Default : 450
69+
*/
70+
open var maxAlertViewWidth: CGFloat? = 450
6271

6372
fileprivate var backgroundImage : UIImageView = UIImageView()
6473
fileprivate var alertView: UIView = {
@@ -164,6 +173,31 @@ open class AABlurAlertController: UIViewController {
164173
"buttonsStackViewHeight": (buttonsStackView.arrangedSubviews.count > 0) ? 40 : 0
165174
]
166175

176+
if let alertViewWidth = alertViewWidth {
177+
self.view.addConstraints(NSLayoutConstraint.constraints(
178+
withVisualFormat: "H:[alertView(alertViewWidth)]", options: [],
179+
metrics: ["alertViewWidth":alertViewWidth], views: viewsDict))
180+
} else {
181+
let widthConstraints = NSLayoutConstraint(item: alertView,
182+
attribute: NSLayoutAttribute.width,
183+
relatedBy: NSLayoutRelation.equal,
184+
toItem: self.view,
185+
attribute: NSLayoutAttribute.width,
186+
multiplier: 0.7, constant: 0)
187+
if let maxAlertViewWidth = maxAlertViewWidth {
188+
widthConstraints.priority = 999
189+
self.view.addConstraint(NSLayoutConstraint(
190+
item: alertView,
191+
attribute: NSLayoutAttribute.width,
192+
relatedBy: NSLayoutRelation.lessThanOrEqual,
193+
toItem: nil,
194+
attribute: NSLayoutAttribute.width,
195+
multiplier: 1,
196+
constant: maxAlertViewWidth))
197+
}
198+
self.view.addConstraint(widthConstraints)
199+
}
200+
167201
let alertSubtitleVconstraint = (alertSubtitle.text != nil) ? "spacing-[alertSubtitle]-" : ""
168202
[NSLayoutConstraint(item: alertView, attribute: .centerX, relatedBy: .equal,
169203
toItem: view, attribute: .centerX, multiplier: 1, constant: 0),
@@ -172,8 +206,6 @@ open class AABlurAlertController: UIViewController {
172206
].forEach { self.view.addConstraint($0)}
173207
[NSLayoutConstraint.constraints(withVisualFormat: "V:|-margin-[alertImage(alertImageHeight)]-spacing-[alertTitle(alertTitleHeight)]-\(alertSubtitleVconstraint)margin-[buttonsStackView(buttonsStackViewHeight)]-margin-|",
174208
options: [], metrics: viewMetrics, views: viewsDict),
175-
NSLayoutConstraint.constraints(withVisualFormat: "H:[alertView(alertViewWidth)]",
176-
options: [], metrics: viewMetrics, views: viewsDict),
177209
NSLayoutConstraint.constraints(withVisualFormat: "H:|-margin-[alertImage]-margin-|",
178210
options: [], metrics: viewMetrics, views: viewsDict),
179211
NSLayoutConstraint.constraints(withVisualFormat: "H:|-margin-[alertTitle]-margin-|",

0 commit comments

Comments
 (0)