-
Notifications
You must be signed in to change notification settings - Fork 2
Setting UILabel's paragraph style linespacing resets alignment to left #83
Comments
You have to provide also alignment. This is intended behaviour.
|
I understand, this is how UIKit works. You set UILabel's alignment center, then attributed string with paragraph without alignment specified and boom, you have alignment left. But, shouldn't Styles shield us from these low level hassles? |
No. This is about single source of truth. You set the style and expect it no side effects. In other words it should clear out everything and apply only the properties which are defined in the style. That way you can reason about it more easily. If this is not the case than its a bug that needs to be fixed.
…Sent from my iPhone
On 9 Nov 2018, at 14:40, Vilém Kurz ***@***.***> wrote:
I understand, this is how UIKit works. You set UILabel's alignment center, then attributed string with paragraph without alignment specified and boom, you have alignment left. But, shouldn't Styles shield us from these low level hassles?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Ok, forget about mixing storyboard settings with Styles (although I think we agreed that Styles should preserve storyboard settings - in other words Styles should not change other values than set through Styles). You even can not do this, in a pure Styles fashion btw read twice what did you write: "expect it no side effects" is mutually exclusive with "it should clear out everything" |
:D you are correct. I misworded that one. What I meant was in that second sentence: Anyway. I personally don't like that idea of preserving settings from storyboard since it can cause lot of confusion, but I will look into it.
this is a bug that needs to be fixed. 👍 |
Set a textstyle like this to a UILabel
The label has alignment set to center in storyboard.
BUG: The label has aligment left after applying the text style. In other words, setting line spacing has a side effect, it resets alignment to left.
EXPECTED BEHAVIOUR: After setting linespacing, the label should keep its alignment setting without any change.
And vice versa. If you set alignment only, line spacing is reset. So, it is not possible to do this:
TextStyle(.paragraphStyle([.alignment(.center)])) + TextStyle(.paragraphStyle([.lineSpacing(2.0)]))
The text was updated successfully, but these errors were encountered: