ealeksandrov / EAIntroView

Highly customizable drop-in solution for introduction views.
MIT License
3.76k stars 501 forks source link

Improve Skip Button customization #182

Open Ying1986 opened 7 years ago

Ying1986 commented 7 years ago

How can I change the height of skip button?

I placed page control to vertical center.

ealeksandrov commented 7 years ago

Pass you custom button with desired frame: https://github.com/ealeksandrov/EAIntroView/blob/6c4f11637f0a8a8b5fe14d14d7c032d701eacadb/Example/Source/ViewController.m#L127-L136

Ying1986 commented 7 years ago

@ealeksandrov

This library is use AutoLayout inner code, so button height changed fit heigh.

So I think you have to add skipbutton height property and add constraint height if user set it,

Can you create skip button with height 100 with your code?

https://github.com/ealeksandrov/EAIntroView/blob/6c4f11637f0a8a8b5fe14d14d7c032d701eacadb/Example/Source/ViewController.m#L127-L136

ealeksandrov commented 7 years ago

Sounds legit. I'll check this.

ealeksandrov commented 7 years ago

Confirmed, will make a note for improving customization in next releases.

chlebta commented 7 years ago

Any update to set height of button ?

Ververtom commented 6 years ago

When customize the skip button, the height is more than 40dp, and I set btn.layer.cornerRadius equals 20, and masks to bouds yes, but the btn was not rounded correctly.

wzbozon commented 6 years ago

There is a workaround. Create blank UIImage of a size that you want you button be and set is as a background.

let skipButton = UIButton(type: .custom)
skipButton.frame = CGRect(x: 0, y: parentView.bounds.size.height - 50, width: parentView.bounds.size.width, height: 50)
let blankImage = UIImage.emptyImage(with: skipButton.frame.size)
skipButton.setBackgroundImage(blankImage, for: .normal)
skipButton.setTitle("Пропустить", for: .normal)
skipButton.backgroundColor = .charcoalGrey
skipButton.setTitleColor(.white, for: .normal)
skipButton.titleLabel?.font = UIFont.systemFont(ofSize: 16)
intro.skipButton = skipButton;
intro.skipButtonY = 50;
intro.skipButtonAlignment = .center

Use this extension to create a blank image:

extension UIImage {

    static func emptyImage(with size: CGSize) -> UIImage? {
        UIGraphicsBeginImageContext(size)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image
    }

}