Add property to adjust width ratio in window (#165)

* Add `maxWidthRatio`
This commit is contained in:
홍성호
2019-08-12 11:41:38 +09:00
committed by Antoine Cœur
parent 8a606e3abf
commit af4f310960
3 changed files with 6 additions and 1 deletions

View File

@@ -41,6 +41,7 @@ final class RootViewController: UIViewController {
appearance.textInsets = UIEdgeInsets(top: 15, left: 20, bottom: 15, right: 20)
appearance.bottomOffsetPortrait = 100
appearance.cornerRadius = 20
appearance.maxWidthRatio = 0.7
}
func configureAccessibility() {

View File

@@ -52,6 +52,7 @@
appearance.textInsets = UIEdgeInsetsMake(15, 20, 15, 20);
appearance.bottomOffsetPortrait = 100;
appearance.cornerRadius = 20;
appearance.maxWidthRatio = 0.7;
}
- (void)configureAccessibility {

View File

@@ -72,6 +72,9 @@ open class ToastView: UIView {
}
}()
/// The width ratio of toast view in window, specified as a value from 0.0 to 1.0.
/// Default value: 0.875
@objc open dynamic var maxWidthRatio: CGFloat = (280.0 / 320.0)
// MARK: UI
@@ -124,7 +127,7 @@ open class ToastView: UIView {
super.layoutSubviews()
let containerSize = ToastWindow.shared.frame.size
let constraintSize = CGSize(
width: containerSize.width * (280.0 / 320.0) - self.textInsets.left - self.textInsets.right,
width: containerSize.width * maxWidthRatio - self.textInsets.left - self.textInsets.right,
height: CGFloat.greatestFiniteMagnitude
)
let textLabelSize = self.textLabel.sizeThatFits(constraintSize)