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

How can I customize width for malert? #11

Open
anfahamid opened this issue Dec 29, 2018 · 5 comments
Open

How can I customize width for malert? #11

anfahamid opened this issue Dec 29, 2018 · 5 comments

Comments

@anfahamid
Copy link

No description provided.

@vitormesquita
Copy link
Owner

Hi @anfahamid sorry my delay,

There is any support to customize malert width. It is a good thing to thinking about.

@idrees88
Copy link

Any update?

@lieudd
Copy link

lieudd commented Aug 28, 2020

same question

@vitormesquita
Copy link
Owner

Hello guys, thank you for using Malert.

This issue has been a long time, so sorry for not supporting you correctly.

Malert does not have this support to set Alert's width, because Malert has an adaptive and flexible layout.

I was thinking here and we can provide a landscape and a portrait margin to be set. Does this approach help you?

@Sangsom
Copy link

Sangsom commented Feb 24, 2022

Just had the same issue with landscape mode so I did a small adjustment in MalertPresentTransitioning.swift file and now at least it doesn't take all the screen height and works for me as expected. Maybe someone will helps this.

extension UIWindow {
    static var isLandscape: Bool {
        if #available(iOS 13.0, *) {
            return UIApplication.shared.windows
                .first?
                .windowScene?
                .interfaceOrientation
                .isLandscape ?? false
        } else {
            return UIApplication.shared.statusBarOrientation.isLandscape
        }
    }
}

class MalertPresentTransitioning: BaseTransitioning, UIViewControllerAnimatedTransitioning {
    let containerHeight: CGFloat = 300
    var originFrame: CGRect {
        switch UIDevice.current.userInterfaceIdiom {
        case .phone:
            if UIWindow.isLandscape {
                return CGRect(
                    x: UIScreen.main.bounds.minX,
                    y: UIScreen.main.bounds.midY - containerHeight / 2,
                    width: UIScreen.main.bounds.width,
                    height: containerHeight)
            } else {
                return UIScreen.main.bounds
            }
        case .pad:
            return CGRect(
                x: UIScreen.main.bounds.minX,
                y: UIScreen.main.bounds.midY - containerHeight / 2,
                width: UIScreen.main.bounds.width,
                height: containerHeight)
        default:
            return UIScreen.main.bounds
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants