evgenyneu / Cosmos

A star rating control for iOS/tvOS written in Swift
MIT License
2.19k stars 368 forks source link

Is there possible to star alignment from right to left? #71

Closed Saravana181187 closed 7 years ago

Saravana181187 commented 7 years ago

I want to align the star from right to left it is possible or not? And my another problem is how to make the stars as center(It mean middle of the cosmos view now it is left side) of the view?

evgenyneu commented 7 years ago

Hi, thanks for the questions.

"I want to align the star from right to left it is possible or not?"

If you want to align the cosmos view to the right edge of the parent view, you can do it with Auto Layout. Cosmos view behaves like any other view, so just add a constraint to the right of the view.

"And my another problem is how to make the stars as center(It mean middle of the cosmos view now it is left side) of the view?"

Sorry, I did not understand what you mean. Can you draw a picture maybe? :)

otymartin commented 7 years ago

@evgenyneu right now the stars either align to the left of the view or the right. By default I would assume the width of the cosmosView would be equal to the width of the number of stars + it's insets instead its width is equal to the width of my parentView meaning when i try to center it in my parentView, it never centers. it just aligns to the left.

Update** Nevermind I found my problem. My autolayout was wrong :(

evgenyneu commented 7 years ago

@Saravana181187, do you still have the issue?

@otymartin, I'm glad you found the solution! 👍

Saravana181187 commented 7 years ago

@evgenyneu , Yes still I have issue.

evgenyneu commented 7 years ago

@Saravana181187, could you tell me more about your issue so I can help? See my questions above.

Saravana181187 commented 7 years ago

I want to set or align stars from right to left, If I swipe right to left means stars want to increase, the first star starts from right side.

evgenyneu commented 7 years ago

@Saravana181187, thanks for explaining. I thought you wanted to align the stars, but it seems that you are asking how to switch the stars to right-to-left mode.

Cosmos view will automatically switch to right to left layout on phones with right to left languages (like Arabic). If your language is left to right, you can switch the language of your phone in iPhone settings to a right to left language. Or, you can change it in Xcode, schema settings > Application language > right to left pseudolanguage.

You can also force the cosmos view to always be in right-to-left mode, even if user has left-to-right language. To do this, set "Force Right-to-Left" in Semantic options of the Attributes inspector for the cosmos view.

Let me know if it helps. :)

Saravana181187 commented 7 years ago

Thank you very much it helps me .

evgenyneu commented 7 years ago

I'm glad it helped.