Skip to content

Instantly share code, notes, and snippets.

@simrandotdev
Created July 20, 2020 06:53
Show Gist options
  • Select an option

  • Save simrandotdev/e544b8a7b83238f41cc3e2755320c4e2 to your computer and use it in GitHub Desktop.

Select an option

Save simrandotdev/e544b8a7b83238f41cc3e2755320c4e2 to your computer and use it in GitHub Desktop.
func boundsAndCenter() {
// Do any additional setup after loading the view.
let v1 = UIView(frame: CGRect(x: 110, y: 110, width: 130, height: 200))
v1.backgroundColor = .green
let v2 = UIView(frame: v1.bounds.insetBy(dx: 10, dy: 10))
v2.backgroundColor = .red
view.addSubview(v1)
v1.addSubview(v2)
// v2.bounds.size.height += 20
// v2.bounds.size.width += 20
print(view.frame)
print(v1.frame)
print(v2.frame)
print(v2.bounds)
// v1.bounds.origin.x += 10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment