在没有子视图的情况下反转UIView

时间:2012-09-12 21:37:13

标签: iphone ios uiview cgaffinetransform

我正在尝试用它上面的一些子视图来反转UIView(UILabels,Buttons等等......)

我是通过

来做的
self.transform = CGAffineTransformMakeScale(-1,1);

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

2 个答案:

答案 0 :(得分:2)

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

CGAffineTransform t = CGAffineTransformMakeScale(-1, 1);
self.transform = t;
for (UIView *subview in self.subviews) {
    subview.transform = t;
}

答案 1 :(得分: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
    }
}