Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Gimp/libgimp/   (Gimp Bildeditor Version 3.2.0©)  Datei vom 14.2.2026 mit Größe 2 kB image not shown  

SSL RTLAligningTextView.swift   Sprache: JAVA

 

import Foundation

/// A `UITextView` subclass which automatically changes its textAlignment based on its content
/// This currently does not work for interactive UITextViews where the user can switch the input method
/// without having entered any text. See `ChatTextView` for how interactive UITextViews are handled.
/// It probably makes sense to handle interactive text views here as well instead of duplicating code.
class RTLAligningTextView: UITextView {
    override public var text: String! {
        didSet {
            if !text.isEmpty {
                textAlignment = text.textAlignment
            }
        }
    }

    override public var attributedText: NSAttributedString! {
        didSet {
            let text = attributedText.string
            if !text.isEmpty {
                textAlignment = text.textAlignment
            }
        }
    }

    // TODO: (IOS-4156) All code below is needed due to a bug which causes text to be cut of when the device language is set to german. The changes enforce the use of TextKit1. Last tested iOS 17.4.1
    var customLayoutManager = NSLayoutManager()

    override var layoutManager: NSLayoutManager {
        customLayoutManager
    }

    override init(frame: CGRect, textContainer: NSTextContainer?) {
        super.init(frame: frame, textContainer: textContainer)
        initCustomLayoutManager()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        initCustomLayoutManager()
    }

    private func initCustomLayoutManager() {
        customLayoutManager.textStorage = textStorage
        customLayoutManager.addTextContainer(textContainer)
        
        textContainer.replaceLayoutManager(customLayoutManager)
    }
}

Messung
CHZG
881009694

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland