Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextAttribtues reset paragraphStyle configured by InterfaceBuilder/Storyboard. #15

Closed
r-plus opened this issue Jul 5, 2016 · 4 comments

Comments

@r-plus
Copy link

r-plus commented Jul 5, 2016

Hi.

When migrate my project to TextAttributes I noticed problem and wrote patch for it that is TextAttributes reset paragraphStyle configured by storyboard even if not changed paragraphStyle parameter.

// `@IBOutlet weak var label: UILabel!` is configured to center alignment via storyboard.

// Native: label is aligned to Center.
let attributedString = NSMutableAttributedString(string: "text")
attributedString.addAttribute(NSBaselineOffsetAttributeName, value: 8, range: NSRange(location: 0, length: 4))
label.attributedText = attributedString

// TextAttributes: label is aligned to Left.
let attributedString = NSMutableAttributedString(string: "text")
let attrs = TextAttributes().baselineOffset(8)
attributedString.addAttributes(attrs)
label.attributedText = attributedString

Is this bug or feature?

My workaround patch is this, but this patch break current TextAttributes behavior.
r-plus@680cf07

P.S. I preferred current simply architecture. We should add .alignment(.Center) chain explicitly.

@delba
Copy link
Owner

delba commented Jul 5, 2016

Hi @r-plus , thanks for your feedback, I really appreciate it!

The example you gave isn't the correct translation of the native snippet though:

let attributedString = NSMutableAttributedString(string: "text")
let attributes = TextAttributes().baselineOffset(8)
attributedString.addAttributes(attributes, range: NSRange(location: 0, length: 4))

Maybe the paragraphStyle configured by storyboard won't be reset if you add the attributes for a given range of the string ?

@r-plus
Copy link
Author

r-plus commented Jul 5, 2016

Thanks for your response.

Try to change explicitly specify range, but no effect.

I publish sample project to reproduce for this issue.
https://github.com/r-plus/textattribute-test

@delba
Copy link
Owner

delba commented Mar 5, 2017

Hey @r-plus, I'm closing this issue. Let's say that TextAttributes doesn't play well with IB/Storyboard ;)
If we try to support this edge case, I bet it will be an endless task 😃

@delba delba closed this as completed Mar 5, 2017
@r-plus
Copy link
Author

r-plus commented Mar 6, 2017

I think so too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants