meMadhav
meMadhav

Reputation: 265

how to set textfield size fix macos swift

I have one textfield "A" with width 150. but whenever I am passing more characters to textfield "A", it is getting overlapped on other textfield "B" characters.

I want textfield "A" to be fixed size and scrollable(mostly right and left).

Thanks in advance.

Upvotes: 0

Views: 237

Answers (3)

Lakshmi Yadav
Lakshmi Yadav

Reputation: 166

You should use Auto-Layeout in your storybook. Set fixed width, trailing space and leading space to your text field.

Upvotes: 1

meMadhav
meMadhav

Reputation: 265

I have added the Auto-Layeouts to my textfields and I have followed below steps:

1) Selected the label.

2) Go to attributes inspector.

3) Select 'Line Breaks' and choose an option Truncate Tail

4) now I can see the text without overlapping with another textField.

Note: But still I am not able to view/Scoll the full text.

Upvotes: 1

Ole Sperlich
Ole Sperlich

Reputation: 11

Just found this piece of code. It might help you

    scrollView.hasHorizontalScroller = true
    textView.maxSize = NSMakeSize(CGFloat(FLT_MAX), CGFloat(FLT_MAX))
    textView.isHorizontallyResizable = true
    textView.textContainer?.widthTracksTextView = false
    textView.textContainer?.containerSize = NSMakeSize(CGFloat(FLT_MAX), CGFloat(FLT_MAX))

Upvotes: -1

Related Questions