简体   繁体   English

如何设置文本字段大小修复 macos swift

[英]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.我有一个宽度为 150 的文本字段“A”。但是每当我将更多字符传递给文本字段“A”时,它就会与其他文本字段“B”字符重叠。

I want textfield "A" to be fixed size and scrollable(mostly right and left).我希望文本字段“A”是固定大小和可滚动的(主要是左右)。

Thanks in advance.提前致谢。

I have added the Auto-Layeouts to my textfields and I have followed below steps:我已将自动布局添加到我的文本字段,并按照以下步骤操作:

1) Selected the label. 1) 选择标签。

2) Go to attributes inspector. 2)转到属性检查器。

3) Select 'Line Breaks' and choose an option Truncate Tail 3)选择“换行符”并选择一个选项截尾

4) now I can see the text without overlapping with another textField. 4) 现在我可以在不与另一个 textField 重叠的情况下看到文本。

Note : But still I am not able to view/Scoll the full text.注意:但我仍然无法查看/整理全文。

You should use Auto-Layeout in your storybook.你应该在你的故事书中使用自动布局。 Set fixed width, trailing space and leading space to your text field.为文本字段设置固定宽度、尾随空格和前导空格

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))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 TextField 大小设置为与 TextField 字符串相同的大小? - How can I set the TextField size to the same size as a TextField String? Swift Set Fix Alignment 在任何 iphone 尺寸上 - Swift Set Fix Alignment on any iphone size Swift-UIAlertcontrller上文本字段的大小 - Swift - size of textfield on UIAlertcontrller 如何将 InputAccessoryView 中的 TextField 设置为第一响应者 [Swift] - How to set TextField in InputAccessoryView as First Responder [Swift] Swift如何修复TextField返回键中的长任务 - Swift How to fix do long task in TextField Return key Swift ui macos 背景透明TextField - Swift ui macos background transparent TextField MacOS 上的 SwiftUI:如何修复 window 大小 - SwiftUI on MacOS: How do I fix the window size 如何将文本字段值从一个 ViewController 传递到第二个 ViewController (MacOS Swift)? - How can I pass a textfield value from one ViewController to a second ViewController (MacOS Swift)? 如何将 TextField 中的更改传达给另一个兄弟视图(Swift UI、Xcode 11.5、macOS Catalina) - How to communicate changes in TextField to another Sibling View (Swift UI, Xcode 11.5, macOS Catalina) 如何在Swift中正确设置TextField的背景颜色和文本颜色 - How to properly set TextField's background color and text color in Swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM