问题
When I Add a set the fram on a CALayer the origin.y is reversed, 0 is at the bottom of it super layer and increasing origin.y moves it up in its super layer. Is there something I did to cause this to be flipped? I would expect origin.y=0 to be the top, not the bottom.
Thanks,
回答1:
You can flip the coordinate system to behave like iOS like this...
layer.sublayerTransform = CATransform3DMakeScale(1.0f, -1.0f, 1.0f);
回答2:
my two cents for UIViewController and swift:
override func viewDidLoad() {
super.viewDidLoad()
#if os(iOS)
let layer = view.layer
layer.sublayerTransform = CATransform3DMakeScale(1.0, -1.0, 1.0)
#endif// no need under OSX. in this way we can use ONE parent controller for iOS and OSX ...
}
来源:https://stackoverflow.com/questions/5176737/calayer-frame-origin-y-is-flipped-0-is-at-the-bottom