mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(core): maxLines support for all text components (#9884)
This commit is contained in:
@@ -13,6 +13,7 @@ import { isString, isNullOrUndefined } from '../../utils/types';
|
||||
import { iOSNativeHelper } from '../../utils';
|
||||
import { Trace } from '../../trace';
|
||||
import { CoreTypes } from '../../core-types';
|
||||
import { maxLinesProperty } from './text-base-common';
|
||||
|
||||
export * from './text-base-common';
|
||||
|
||||
@@ -197,6 +198,24 @@ export class TextBase extends TextBaseCommon {
|
||||
this._setShadow(value);
|
||||
}
|
||||
|
||||
[maxLinesProperty.setNative](value: CoreTypes.MaxLinesType) {
|
||||
const nativeTextViewProtected = this.nativeTextViewProtected;
|
||||
const numberOfLines = this.whiteSpace === 'normal' ? value : 1;
|
||||
if (nativeTextViewProtected instanceof UITextView) {
|
||||
nativeTextViewProtected.textContainer.maximumNumberOfLines = numberOfLines;
|
||||
|
||||
if (value !== 0) {
|
||||
nativeTextViewProtected.textContainer.lineBreakMode = NSLineBreakMode.ByTruncatingTail;
|
||||
} else {
|
||||
nativeTextViewProtected.textContainer.lineBreakMode = NSLineBreakMode.ByWordWrapping;
|
||||
}
|
||||
} else if (nativeTextViewProtected instanceof UILabel) {
|
||||
nativeTextViewProtected.numberOfLines = numberOfLines;
|
||||
} else if (nativeTextViewProtected instanceof UIButton) {
|
||||
nativeTextViewProtected.titleLabel.numberOfLines = numberOfLines;
|
||||
}
|
||||
}
|
||||
|
||||
_setColor(color: UIColor): void {
|
||||
if (this.nativeTextViewProtected instanceof UIButton) {
|
||||
this.nativeTextViewProtected.setTitleColorForState(color, UIControlState.Normal);
|
||||
|
||||
Reference in New Issue
Block a user