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

how can i change the post text without changing the icon #15

Open
ghost opened this issue Oct 1, 2017 · 3 comments
Open

how can i change the post text without changing the icon #15

ghost opened this issue Oct 1, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Oct 1, 2017

i have a button but i want to change the post text only not the button how can i complete that

@ranesr
Copy link
Owner

ranesr commented Oct 1, 2017

Can you explain it more? I did not understand what you meant.

@ghost
Copy link
Author

ghost commented Oct 1, 2017

I have a uibutton pretext with an icon that will need to constantly be update now when this this update i dont want the icon to be update because this will remove the view and renter the view into the view again.

this is what im using right now
myButton.setIcon(prefixText: "", icon: .googleMaterialDesign(.print), postfixText: " 66", forState: .normal)

i want to update by doing this
myButton.postfixText = "my postfix text here "

@leesherwood
Copy link

If you look at the source you'll see that the prefix, postfix and icon are all concatenated together with the various attributed string attributes for each.

https://github.com/ranesr/SwiftIcons/blob/master/Source/SwiftIcons.swift#L321

So there is currently no way of changing just one of the 3 components, as the "settings" are not stored anywhere.

The simplest solution would be to create a custom UIButton, that has the 3 component parts (maybe have a "text" and "attributes dictionary" for each part. Then use the didSet closure to re-run the setIcon function, whenever any of those properties change.

@ranesr seems to have taken the simplest approach to integrate the icon's, which I prefer over bloated libraries with 100's of components to support all the various possibilities. So i'm not too sure whether such components would be a welcome addition to this library, or if it would better too "roll your own" library based on this one. Maybe ranesr can make his vision known for this library, so we know whether contributing back custom components is worthwhile, or if he prefer's too keep things simple.

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

No branches or pull requests

2 participants