evgenyneu / swift-badge

A badge view for iOS/tvOS written in Swift
MIT License
394 stars 107 forks source link

different shape and arrow #14

Open Rufy86 opened 7 years ago

Rufy86 commented 7 years ago

it's possible to add and arrow like disclosure indicator to the badge? And it's possible have different shape?

evgenyneu commented 7 years ago

Hi @Rufy86, thanks for the questions.

it's possible to add and arrow like disclosure indicator to the badge?

Sorry, could you specify what you mean by the arrow? Do you want the badge to have the arrow shape, or do you want to place a smaller arrow inside an oval-shaped badge?

And it's possible have different shape?

Currently one can alter the shape of the badge by changing the insets and cornerRadius properties. With this one can achieve all kinds of rectangular, oval or round shapes. If you want to have a different shape, like a triangle, for example, it's not possible at the moment, unfortunately.

Rufy86 commented 7 years ago

@evgenyneu thanks the answer

Sorry, could you specify what you mean by the arrow? yes I can.

Do you want the badge to have the arrow shape, or do you want to place a smaller arrow inside an oval-shaped badge? well, both!

for example, if you see this project, MLPAccessoryBadge, this badge has different shape and some of these have an arrow. some arrow is attached to badge, also has some space.

in this project the different badges are already made and the user has only choose the shape to use.

it's possible make the same thing?

I'm using your badge in a table view, but I can't insert the disclosure indicator, because insert the badge in the accessoryView. if the badge has the disclosure indicator build-in , it's better. or I think.

what do you think about?

evgenyneu commented 7 years ago

MLPAccessoryBadge is a very nice badge indeed, thanks for the suggestion. I have added it to the list of recommended libraries.

I think this variable shape feature is very nice. It is not currently possible with this library, as you already know. To be honest, I don't think it is worth adding it to this library, since there is already MLPAccessoryBadge that is doing it very well. I would rather keep this library simple, so it is a "does one thing and does it well" kind of thing. :)

Rufy86 commented 7 years ago

@evgenyneu thank you for the answer,

does one thing and does it well

it's a great think way, but the problems of MLPAccessoryBadge are: 1) it isn't update since 4 years; 2) is written in Objective-C.

your badge is written in swift and could have big potential.

however, you can add at least the arrow like disclosure indicator?

evgenyneu commented 7 years ago

Yeah, it is a good idea, I agree. However, I don't know any simple way of adding an arrow or the disclosure indicator to this library. This library is just a very simple subclass of a Label that draws an oval in its background. Is there an easy way of drawing an arrow or a disclosure indicator without sacrificing the simplicity?

Rufy86 commented 7 years ago

I'll try to search about it. but I think that the answer could be also in MPLAccessoryBadge.

but I've found something in internet: check these

http://swiftiostutorials.com/tutorial-draw-nice-triangle-view-border-cashapelayer/ https://www.raywenderlich.com/38918/paintcode-tutorial-bezier-paths https://github.com/mukeshthawani/TriLabelView https://gist.github.com/mayoff/4146780

evgenyneu commented 7 years ago

Hi @Rufy86, thanks for the research! Feel free to implement this in the library if you want. I will merge it if it is a simple solution that does not involve a lot of code lines.

chanders commented 7 years ago

@evgenyneu think that he is speaking about the "disclosure" arrow that tableviews come with.

@Rufy86 all you need to do is enable "disclosure" arrows in storyboard and then proceed to add the badge :)

screen shot 2017-07-01 at 6 58 30 pm