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

FAB button image not showing after init #907

Closed
0xTomDaniel opened this issue Oct 14, 2017 · 14 comments
Closed

FAB button image not showing after init #907

0xTomDaniel opened this issue Oct 14, 2017 · 14 comments

Comments

@0xTomDaniel
Copy link

I have created a FAB button using fabButton = FABButton(image: Icon.cm.add, tintColor: Color.grey.darken3) but the image does not display until the button is touched.

I have tried setting the image outside of init which still does not work.

@daniel-jonathan
Copy link
Member

Would you be able to send me a sample showing this? Is this tested on the simulator or device? What version of Material are you using? Thank you!

@daniel-jonathan
Copy link
Member

Hey! I haven't heard from you. When you have a sample project reproducing the issue, please reopen this. Thank you!

@0xTomDaniel
Copy link
Author

0xTomDaniel commented Oct 16, 2017

Here is a xcode project that I created that reproduces this issue: https://github.com/tomdaniel0x01/fab-menu-bug

I am using Material (2.12.1) and it happens on both the simulator and the device.

@daniel-jonathan
Copy link
Member

Thank you! I will take a look :)

@daniel-jonathan
Copy link
Member

@tomdaniel0x01 So I found the bug. The issue arises because the size is being set after the left and bottom positioning. I am looking into it. You can workaround this issue by moving the size constraint before the position constraints:

view.layout(fabMenu).size(CGSize(width: 56, height: 56)).bottom(17).left(10)

@daniel-jonathan
Copy link
Member

The issue has been completely resolved in Material 2.12.3. Thank you for sharing this issue. All the best!

@0xTomDaniel
Copy link
Author

@DanielDahan Thank you so much!

@yasirmturk
Copy link

this fix broke something inside the button and now titleEdgeInsets and imageEdgeInsets are not working properly for Button, IconButton

@daniel-jonathan
Copy link
Member

@yasirmturk Can you share a sample or some code that demonstrates this and your usage?

@yasirmturk
Copy link

I am aligning icon and text in horizontal centered position and for that is used this code
`extension Button {
// MARK: - UIButton+Aligment

func alignContentHorizontally(spacing: CGFloat = 4.0) {
    contentHorizontalAlignment = .left
    contentVerticalAlignment = .top
    
    let imageWidth = (currentImage?.width)!
    let imageLeft = (layer.width - imageWidth) / 2
    let titleLeft = ((layer.width - (titleLabel?.layer.width)!) / 2) - imageWidth
    imageEdgeInsets = UIEdgeInsetsMake(spacing, imageLeft, 0, 0)
    titleEdgeInsets = UIEdgeInsetsMake(24 + (spacing * 2), titleLeft, 0, 0)
}

}`
to get this:
iconbuttons-tabbar-2_12_2
It was working perfect till version 2.12.2 but after updating to version 2.12.3 it became this:
2 12 3

@daniel-jonathan
Copy link
Member

daniel-jonathan commented Oct 25, 2017

@yasirmturk Can you send over a sample of this, so I can reproduce the issue? As well, I would open a new issue for this, as now this issue has been closed and the description at the top is not describing the issue you are facing. Thank you!

@yasirmturk
Copy link

you can use the code i have posted to reproduce the issue... just make any button with both icon and text and run it with both 2.12.2 and 2.12.3 you will see

@daniel-jonathan
Copy link
Member

@yasirmturk Please open a new issue for this. Tagging this issue on the current one is not effective. Thank you :)

@yasirmturk
Copy link

okay

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

No branches or pull requests

3 participants