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

UIBarButtonItem is not aligned #7

Closed
yeralin opened this issue Jun 5, 2017 · 5 comments
Closed

UIBarButtonItem is not aligned #7

yeralin opened this issue Jun 5, 2017 · 5 comments
Assignees
Labels

Comments

@yeralin
Copy link

yeralin commented Jun 5, 2017

Hi, I'm using SwiftIcons library (installed though Pod).

I'm trying to create UIBarButtonItem with specific icon.
I set it like this:
menuButton.setIcon(icon: .ionicons(.navicon), iconSize: 35, color: systemColor)
where systemColor == UIView().tintColor
But with this setup, my UIBar looks like this:
image
As, you can see it is not aligned vertically (I tried using SetTitlePositionAdjustment, but I can adjust only horizontal position).

I kinda fixed the position by using:
menuButton.setIcon(prefixText: "", icon: .ionicons(.navicon), iconColor: systemColor, postfixText: "", cgRect: CGRect(x: 30, y: 30, width: 30, height: 30), size: 35, iconSize: 36)
image

But, then button is not tappable...

Can anyone help me here?

@yeralin
Copy link
Author

yeralin commented Jun 6, 2017

@ranesr

@ranesr ranesr added the bug label Jun 6, 2017
@ranesr ranesr self-assigned this Jun 7, 2017
@ranesr
Copy link
Owner

ranesr commented Jun 7, 2017

Please Check Release 1.5.

@ranesr ranesr closed this as completed Jun 7, 2017
@ranesr
Copy link
Owner

ranesr commented Jun 7, 2017

I have added Example 3 (Icon with custom cgRect) in README.

@yeralin
Copy link
Author

yeralin commented Jun 7, 2017

@ranesr thank you :) I was already trying to fix myself. You were faster :D

@yeralin
Copy link
Author

yeralin commented Jun 7, 2017

We gotta little problem here.
Since it is a custom button, with your new change, fading effect on button press is gone now.
I was able to fix it by modifying function like this:

public func setIcon(icon: FontType, iconSize: CGFloat, color: UIColor = .black, cgRect: CGRect, target: AnyObject?, action: Selector) {
        title = nil
        let button = UIButton(frame: cgRect)
        let onPressColor = color.withAlphaComponent(0.4)
        button.setIcon(icon: icon, iconSize: iconSize, color: color, forState: .normal)
        button.addTarget(target, action: action, for: .touchUpInside)
        button.setTitleColor(onPressColor, for: .highlighted)
        customView = button
    }

If you approve, I will create a PR

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

No branches or pull requests

2 participants