Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ([self.txtOutputTranslator baseWritingDirectionForPosition:[self.txtOutputTranslator beginningOfDocument] inDirection:UITextStorageDirectionForward] == UITextWritingDirectionLeftToRight)
- {
- self.txtOutputTranslator.textAlignment=NSTextAlignmentLeft;
- }
- else
- {
- self.txtOutputTranslator.textAlignment=NSTextAlignmentRight;
- }
- func textViewDidChange(_ textView: UITextView) {
- let baseWritingDirection = textView.baseWritingDirection(for: textView.beginningOfDocument, in: .forward)
- switch baseWritingDirection {
- case .leftToRight:
- textView.textAlignment = .left // for example
- case .rightToLeft:
- textView.textAlignment = .right // for example
- case .natural:
- // WARNING: use natural alignment carefully as it won't work with reusable table view cells. In common cases baseWritingDirection won't return this parameter
- textView.textAlignment = .natural
- }
- }
Add Comment
Please, Sign In to add comment