CaliCastle / PopMenu

A fully customizable popup style menu for iOS 😎
https://popmenu.cali.so
MIT License
1.62k stars 185 forks source link

PopMenuDefaultAction.iconWidthHeight is a static property #9

Closed shalyf closed 6 years ago

shalyf commented 6 years ago

This is a cool popup menu, I like it, and I will use it in my project. But when I add my icon image(size 18 pixel) to PopMenuDefaultAction, It looks ugly. The image is much bigger than I expected. So I looked at the source code and found a problem.

PopMenuDefaultAction.iconWidthHeight is a static property, I think it should be automatically calculated.

NSLayoutConstraint.activate([
                iconImageView.widthAnchor.constraint(equalToConstant: PopMenuDefaultAction.iconWidthHeight),
                iconImageView.heightAnchor.constraint(equalTo: iconImageView.widthAnchor),
                iconImageView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: PopMenuDefaultAction.iconLeftPadding),
                iconImageView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
            ])

iconImageView.widthAnchor and iconImageView.heightAnchor should be automatically calculated based on the size of the image.

Now I am using a custom PopMenuAction named PopMenuCustomAction and modifying PopMenuDefaultAction.iconWidthHeight to 18 to resolve my problem.

Please fix this issue, Thanks.

CaliCastle commented 6 years ago

Hi!

Thanks for finding this issue! I was initially going to make this become a variable that's modifiable but forgot along the way.

This will be resolved in the upcoming patch (v1.1.3)

CaliCastle commented 6 years ago

simulator screen shot - iphone x - 2018-09-02 at 23 26 26

It'll be added to PopMenuDefaultAction and you can directly configure it like:

let action = PopMenuDefaultAction(title: "Some Title", image: UIImage(named: "blah"), color: .gray)
action.iconWidthHeight = 45
shalyf commented 6 years ago

@CaliCastle Thanks.

CaliCastle commented 6 years ago

Hi @shalyf,

The suggested enhancement is completed in v2.1.1, let me know if there's any issue or bug, thanks again!