텍스트 뷰가 속한보기의 크기를 조정하고보기가 커지거나 작아지면 텍스트가 흔들립니다.보기 크기 조정시 텍스트 뷰 흔들림
선언의 텍스트보기 말했다
lazy var textview: UITextView = {
let textView = UITextView()
textView.text = ""
textView.font = .systemFont(ofSize: 12, weight: UIFontWeightMedium)
textView.isScrollEnabled = false
textView.isEditable = false
textView.isSelectable = true
textView.isUserInteractionEnabled = true
textView.translatesAutoresizingMaskIntoConstraints = false
textView.textAlignment = .center
textView.textColor = .lightGray
textView.dataDetectorTypes = .link
return textView
}()
내가 그것을 그렇게되면이
if let window = UIApplication.shared.keyWindow {
let statusBarHeight = UIApplication.shared.statusBarFrame.size.height
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveLinear, animations: {
self.frame = CGRect(x: 0, y: statusBarHeight, width: window.frame.width, height: window.frame.height - statusBarHeight)
self.layer.cornerRadius = 0
self.layoutIfNeeded()
}, completion: nil)
}
처럼 전체 화면에 맞게에 있다고보기의 크기를 조정하고있어,보기는 완벽하게 확장하지만, textviews 텍스트는 애니메이션을 매우 전문적이지 않게 만드는 바운스 효과를냅니다 ... 조언이 있습니까?
편집 : 센터 텍스트 정렬 옵션을 제거해도 문제가없는 것 같습니다. 텍스트 센터를 정렬하여 작동하게하려면 어떻게해야합니까?
이 문제의 원인이 아니라 코드가 이해되지 않는다 점에 유의하시기 바랍니다. 왜 layoutIfNeeded 호출 프레임을 변경하고 있습니까? – matt
@matt layoutIfNeeded를 제거하면 애니메이션이 부드러워집니다. 왜 그런지 모르겠습니다. 감사합니다 – Walker
@ matt 내가 textviews 제약 조건을 제거해야 프레임을 움직이는 .. 그리고 그들을 readd? 모든 것은 괜찮아요. 이상한 튀는 효과를내는 textviews 텍스트 일뿐입니다. – Walker