DVSwitch icon indicating copy to clipboard operation
DVSwitch copied to clipboard

Suggestion

Open inb4ohnoes opened this issue 9 years ago • 2 comments

Hey, I'd just like to say first that this is a fantastic control. Thanks for building it!

In my own personal branch, I've changed all the UILabels you've been using to UIButtons. The reason for this is I wanted to support images instead of text.

Why did I choose UIButton? Well, mostly for laziness, but also convenience. UIButton acts similarly to UILabel (it contains one), but also contains an image view as well as a background image view. In addition, image view + label layout is automatically handled. This is a convenience for people who might want image + text.

What about tint color? Well, there's a method on UIImage, imageWithRenderingMode, where you can set the property UIImageRenderingModeAlwaysTemplate which will ignore color values of the original image and apply any given UIColor to any non-0-alpha part of the image.

My version currently has no API changes, as the support is mostly just shoehorned on there. However, If you would like, I can submit a PR. You'll have to tell me what you want though, as I can do one of two things:

change the default initializers to something like - (instancetype)initWithStringsArray:(NSArray *)strings andImageStringsArray:(NSArray *)imageStrings;

if users don't want a part, they can pass nil for any given argument, or selectively pass [NSNull null] for any index in the arrays.

Or add an additional initializer for both regular strings and attributed string that support images in additional to text.

Let me know!

inb4ohnoes avatar Jul 13 '15 17:07 inb4ohnoes

Hey! Thanks for your feedback! I'd love if you could create a pull request with buttons instead of labels as alternative initializers, so for people who have labels it will work the same, and for people who want buttons there will be new methods. What I mean is separate code path for those who want buttons with new initializing methods, keeping the labels as they are. I'm all for positive changes, while keeping the old behaviour and API for those who need it.

It would be great if you would make a pull request with all your changes but not breaking the API. If this is too much to ask for - I understand.

Regards!

Voley avatar Jul 13 '15 17:07 Voley

Hey, thanks for the quick response!

I can absolutely make a PR for the changes. So as I understand, you will want two additional methods in addition for the current initializers that are existing. That is totally possible.

Here is a preview of what this change might look like. These are tinted with the method I described above.

I am actually currently developing this app, so it might take a bit to clean up and submit a PR; I hope you understand!

inb4ohnoes avatar Jul 13 '15 17:07 inb4ohnoes