Skip to content

Commit dc251fb

Browse files
Fixed RTL issues with iOS 26
1 parent 766f5f6 commit dc251fb

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

Example/perian_justify_example/ViewController.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ extension ViewController {
5353
fullWidthLabel2.numberOfLines = 0
5454
halfWidthLabel1.numberOfLines = 0
5555
halfWidthLabel2.numberOfLines = 0
56+
if #available(iOS 26.0, *) {
57+
fullWidthLabel1.fixDirectionForiOS26()
58+
fullWidthLabel2.fixDirectionForiOS26()
59+
halfWidthLabel1.fixDirectionForiOS26()
60+
halfWidthLabel2.fixDirectionForiOS26()
61+
}
5662
}
5763

5864
func fillLabels() {

Sources/PersianJustify/Extensions/String.toPJString(in).swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@ extension String {
1515
return toPJString(fittingWidth: parentWidth, font: font)
1616
}
1717
}
18+
19+
extension UILabel {
20+
21+
@available(iOS 26.0, *)
22+
func fixDirectionForiOS26() {
23+
if let traitOverrides = value(forKey: "traitOverrides") as? NSObject {
24+
if traitOverrides.responds(to: NSSelectorFromString("setResolvesNaturalAlignmentWithBaseWritingDirection:")) {
25+
traitOverrides.setValue(true, forKey: "resolvesNaturalAlignmentWithBaseWritingDirection")
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)