MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / adjustLineBreak

Method adjustLineBreak

packages/core/ui/button/index.ios.ts:198–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

196 }
197
198 private adjustLineBreak() {
199 const whiteSpace = this.whiteSpace;
200 const textOverflow = this.textOverflow;
201 const nativeView = this.nativeViewProtected.titleLabel;
202 switch (whiteSpace) {
203 case 'wrap':
204 case 'normal':
205 nativeView.lineBreakMode = NSLineBreakMode.ByWordWrapping;
206 nativeView.numberOfLines = this.maxLines;
207 break;
208 case 'initial':
209 nativeView.lineBreakMode = NSLineBreakMode.ByTruncatingMiddle;
210 nativeView.numberOfLines = 1;
211 break;
212 case 'nowrap':
213 switch (textOverflow) {
214 case 'clip':
215 nativeView.lineBreakMode = NSLineBreakMode.ByClipping;
216 nativeView.numberOfLines = this.maxLines;
217 break;
218 case 'ellipsis':
219 nativeView.lineBreakMode = this.direction === CoreTypes.LayoutDirection.rtl ? NSLineBreakMode.ByTruncatingHead : NSLineBreakMode.ByTruncatingTail;
220 nativeView.numberOfLines = 1;
221 break;
222 default:
223 nativeView.lineBreakMode = NSLineBreakMode.ByTruncatingMiddle;
224 nativeView.numberOfLines = 1;
225 break;
226 }
227 break;
228 }
229 }
230
231 public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
232 // If there is text-wrap UIButton.sizeThatFits will return wrong result (not respecting the text wrap).

Calls

no outgoing calls

Tested by

no test coverage detected