【发布时间】:2018-06-15 23:16:46
【问题描述】:
我试图创建一个文本视图,旋转它并在其中显示一些文本。我可以创建和旋转 UITextView,但文本在我的 UITextView 中的行尾之前中断到下一行。
let textView = UITextView(frame: CGRect(x: 0, y: 0, width: 300, height: 200))
textView.transform = CGAffineTransform(rotationAngle: .pi / 2)
textView.text = "This is some long sample text to show the issue I am facing. Notice that the text is broken onto the next line well before the end of the UITextView."
textView.backgroundColor = .red
textView.center = view.center
view.addSubview(textView)
问题:
确定问题
但是,如果我不旋转 textview(通过从上面注释掉以下行),文本不会在 UITextView 结束之前中断到下一行。所以,这个问题似乎是由旋转图像引起的,但我不明白为什么或如何解决这个问题。
textView.transform = CGAffineTransform(rotationAngle: .pi / 2)
为什么文本仅在旋转时才在 UITextView 中间中断到下一行,如何解决此问题?
【问题讨论】:
标签: ios swift rotation uitextview cgaffinetransform