为什么iOS坐标系很难理解? 只有我?

我正在学习iOS的UIView! 而且我发现我无法理解边界是如何工作的。

例如, 我的代码

请运行这个代码…并看到红框的移动。 红色框上升! 而白根视图是静态的!

为什么!? 为什么红框上升! ?? 请让我知道OTL!

class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let childView : UIView = UIView(frame: CGRect(x: 50, y: 50, width: 200, height: 200) ) childView.backgroundColor = UIColor.red self.view.addSubview(childView) } override func viewDidAppear(_ animated: Bool) { UIView.animate(withDuration: 8, animations: { // I cannot unnerstand how bounds works!! self.view.bounds = CGRect(x: 0, y: -300, width:self.view.bounds.width, height: 700) //I can understand how frame works self.view.frame = CGRect(x: 200, y: 0, width: self.view.bounds.width, height: self.view.frame.height) }) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } 

我读了这篇文章 ,但我不明白

 CompositedPosition.x = View.frame.origin.x - Superview.bounds.origin.x; CompositedPosition.y = View.frame.origin.y - Superview.bounds.origin.y; 

这里! 这是对的(根据我的testing,这是正确的),但是,我不知道为什么。 为什么不“View.frame.origin.x + Superview.bounds.origin.x”?

如果我们改变视图范围的起源,视图在屏幕上移动,从原点(或位置)的angular度来看,“范围”和“范围”有什么区别? 除了简单的反向操作之外,还有其他的区别吗?

基本上,UIView的边界是矩形,表示为相对于其自身坐标系(0,0)的位置(x,y)和大小(宽度,高度)。

UIView的框架是矩形,表示为相对于包含在其中的超级视图的位置(x,y)和大小(宽度,高度)。

请按照此链接清楚的例子。 cocoa:框架和界限有什么区别?