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

Improve Skip Button customization #182

Open
Ying1986 opened this issue Sep 16, 2016 · 7 comments
Open

Improve Skip Button customization #182

Ying1986 opened this issue Sep 16, 2016 · 7 comments

Comments

@Ying1986
Copy link

How can I change the height of skip button?

I placed page control to vertical center.

@ealeksandrov
Copy link
Owner

Pass you custom button with desired frame:

UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setFrame:CGRectMake(0, 0, 230, 40)];
[btn setTitle:@"SKIP NOW" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
btn.layer.borderWidth = 2.f;
btn.layer.cornerRadius = 10;
btn.layer.borderColor = [[UIColor whiteColor] CGColor];
intro.skipButton = btn;
intro.skipButtonY = 60.f;
intro.skipButtonAlignment = EAViewAlignmentCenter;

@Ying1986
Copy link
Author

Ying1986 commented Sep 16, 2016

@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?

UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setFrame:CGRectMake(0, 0, 230, 40)];
[btn setTitle:@"SKIP NOW" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
btn.layer.borderWidth = 2.f;
btn.layer.cornerRadius = 10;
btn.layer.borderColor = [[UIColor whiteColor] CGColor];
intro.skipButton = btn;
intro.skipButtonY = 60.f;
intro.skipButtonAlignment = EAViewAlignmentCenter;

@ealeksandrov
Copy link
Owner

Sounds legit. I'll check this.

@ealeksandrov
Copy link
Owner

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

@ealeksandrov ealeksandrov changed the title Skip Button height. Improve Skip Button customization Nov 5, 2016
@chlebta
Copy link

chlebta commented Apr 14, 2017

Any update to set height of button ?

@Ververtom
Copy link

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
Copy link
Contributor

wzbozon commented Aug 18, 2018

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

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