Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for set text label constraint size to adjust the maximum … #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Sources/IHProgressHUD/IHProgressHUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class IHProgressHUD : UIView {
private var defaultMaskType = IHProgressHUDMaskType.none
private var defaultAnimationType = IHProgressHUDAnimationType.flat
private var containerView: UIView?
private var labelConstraintSize = CGSize(width: 200.0, height: 300.0)
private var minimumSize = CGSize(width: 50, height: 50)
private var ringThickness: CGFloat = 2.0
private var ringRadius: CGFloat = 18.0
Expand Down Expand Up @@ -783,9 +784,8 @@ public class IHProgressHUD : UIView {
var labelWidth: CGFloat = 0.0

if getStatusLabel().text != nil {
let constraintSize = CGSize(width: 200.0, height: 300.0)
labelRect = getStatusLabel().text?.boundingRect(
with: constraintSize,
with: labelConstraintSize,
options: [.usesFontLeading, .truncatesLastVisibleLine, .usesLineFragmentOrigin],
attributes: [NSAttributedString.Key.font: getStatusLabel().font ?? UIFont.systemFont(ofSize: 15)],
context: nil) ?? CGRect.zero
Expand Down Expand Up @@ -1175,6 +1175,10 @@ extension IHProgressHUD {
sharedView.containerView = containerView
} // default is window level

public class func set(labelConstraintSize size: CGSize) {
sharedView.labelConstraintSize = size
} // default is 200x300 pt

public class func set(minimumSize: CGSize) {
sharedView.minimumSize = minimumSize
} // default is CGSizeZero, can be used to avoid resizing for a larger message
Expand Down