FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(ios-textview): text alignment reset to default on blur by manoldonev · Pull Request #6903 · NativeScript/NativeScript · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 9 additions & 1 deletion tns-core-modules/ui/text-base/text-base.ios.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ export class TextBase extends TextBaseCommon {
paragraphStyle.lineBreakMode = this.nativeTextViewProtected.lineBreakMode;
}
attrText.addAttributeValueRange(NSParagraphStyleAttributeName, paragraphStyle, { location: 0, length: attrText.length });
} else if (this.nativeTextViewProtected instanceof UITextView) {
const paragraphStyle = NSMutableParagraphStyle.alloc().init();
paragraphStyle.alignment = (<UITextView>this.nativeTextViewProtected).textAlignment;
attrText.addAttributeValueRange(NSParagraphStyleAttributeName, paragraphStyle, { location: 0, length: attrText.length });
}

if (this.nativeTextViewProtected instanceof UIButton) {
Expand Down Expand Up @@ -174,6 +178,7 @@ export class TextBase extends TextBaseCommon {
dict.set(NSKernAttributeName, style.letterSpacing * this.nativeTextViewProtected.font.pointSize);
}

const isTextView = this.nativeTextViewProtected instanceof UITextView;
if (style.lineHeight) {
const paragraphStyle = NSMutableParagraphStyle.alloc().init();
paragraphStyle.lineSpacing = style.lineHeight;
Expand All @@ -184,9 +189,12 @@ export class TextBase extends TextBaseCommon {
paragraphStyle.lineBreakMode = this.nativeTextViewProtected.lineBreakMode;
}
dict.set(NSParagraphStyleAttributeName, paragraphStyle);
} else if (isTextView) {
const paragraphStyle = NSMutableParagraphStyle.alloc().init();
paragraphStyle.alignment = (<UITextView>this.nativeTextViewProtected).textAlignment;
dict.set(NSParagraphStyleAttributeName, paragraphStyle);
}

const isTextView = this.nativeTextViewProtected instanceof UITextView;
if (style.color && (dict.size > 0 || isTextView)) {
dict.set(NSForegroundColorAttributeName, style.color.ios);
}
Expand Down

Back | FazBrowse Home | New Git URL