hsousa / HCSStarRatingView

Simple star rating view for iOS written in Objective-C
MIT License
1.28k stars 194 forks source link

RTL support #43

Open nickolas-pohilets opened 8 years ago

nickolas-pohilets commented 8 years ago

Hello, I've added support for flipping control for RTL languages, and fixed couple compiler warnings. Let me know if you have any comments.

Could you pls merge in back and bump version in the podspec?

nickolas-pohilets commented 7 years ago

I don't have any objections to remove the property - in my code I'm always setting it to YES. I've added property for backward compatibility with existing code.

Also there is already a property semanticContentAttribute in UIView. Probably using that one would be the better approach.

hsousa commented 7 years ago

Interesting, I didn't know about semanticContentAttribute. 🤔

So maybe besides ditching the property, _shouldFlip should return YES if:

That would cover automatically flipping the content when a user has the device in a RTL language, but also if someone decides he wants to manually force the direction.

What do you think?

nickolas-pohilets commented 7 years ago

If self.semanticContentAttribute == UISemanticContentAttributeForceLeftToRight, then _shouldFlip should return NO regardless of [UIApplication sharedApplication].userInterfaceLayoutDirection.

Starting from iOS 10, there is a nice property: @property (readonly, nonatomic) UIUserInterfaceLayoutDirection effectiveUserInterfaceLayoutDirection which computes layout direction with respect to:

Starting from iOS 9, there is a class method +[UIView userInterfaceLayoutDirectionForSemanticContentAttribute:] that does not take self.traitCollection.layoutDirection into account.

Before iOS 9, semantic content does not exists, so I think just [UIApplication sharedApplication].userInterfaceLayoutDirection can be used.

hsousa commented 7 years ago

Hi again! Wow, thanks a lot for the rich information on this subject! 😍

So it sounds like we should use _shouldFlip internally and inside that decide what to return based on API availability/OS version:

Or do you think it's also worth it to validate self.traitCollection.layoutDirection on iOS 9?

Thanks for helping out with this and for the great followup!