EAIntroView icon indicating copy to clipboard operation
EAIntroView copied to clipboard

Improve Skip Button customization

Open Ying1986 opened this issue 9 years ago • 7 comments

How can I change the height of skip button?

I placed page control to vertical center.

Ying1986 avatar Sep 16 '16 09:09 Ying1986

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

ealeksandrov avatar Sep 16 '16 12:09 ealeksandrov

@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

Ying1986 avatar Sep 16 '16 15:09 Ying1986

Sounds legit. I'll check this.

ealeksandrov avatar Sep 16 '16 17:09 ealeksandrov

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

ealeksandrov avatar Nov 05 '16 15:11 ealeksandrov

Any update to set height of button ?

chlebta avatar Apr 14 '17 13:04 chlebta

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.

Ververtom avatar Dec 13 '17 10:12 Ververtom

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
    }
    
}

wzbozon avatar Aug 18 '18 08:08 wzbozon