1

我正在尝试反转带有一些子视图的 UIView(UILabels、按钮等......)

我这样做是通过

self.transform = CGAffineTransformMakeScale(-1,1);

有没有一种简单的方法可以防止子视图被反转

4

2 回答 2

2

您可以对所有子视图应用相同的变换,以便将它们反转两次:

CGAffineTransform t = CGAffineTransformMakeScale(-1, 1);
self.transform = t;
for (UIView *subview in self.subviews) {
    subview.transform = t;
}
于 2012-09-12T22:11:44.210 回答
0
///Reverse the Tabs from RightToLeft
public func rightToLeft() {
    let t = CGAffineTransform.init(scaleX: -1, y: -1)
    self.transform = t
    self.subviews.forEach { (subview) in
        subview.transform = t
    }
}

///Reverse the Tabs from LeftToRight
public func leftToRight() {
    let t = CGAffineTransform.init(scaleX: 1, y: 1)
    self.transform = t
    self.subviews.forEach { (subview) in
        subview.transform = t
    }
}
于 2018-04-02T05:43:03.080 回答