Created
April 26, 2024 16:43
-
-
Save ulkomar/aa0f4c7cf286858c39a23f1b46c6b444 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
class CoordinateSystem: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Main view | |
view.backgroundColor = .black | |
view.frame = CGRect(x: 0, y: 0, width: 500, height: 500) | |
// Red view | |
let redView = UIView(frame: CGRect(x: 20, y: 20, width: 460, height: 460)) | |
redView.backgroundColor = .red | |
view.addSubview(redView) | |
// Blue view | |
let blueView = UIView(frame: CGRect(x: 20, y: 20, width: 420, height: 420)) | |
blueView.backgroundColor = .blue | |
redView.addSubview(blueView) | |
// Orange view | |
let orangeView = UIView(frame: CGRect(x: 20, y: 20, width: 380, height: 380)) | |
orangeView.backgroundColor = .orange | |
blueView.addSubview(orangeView) | |
// Yellow view | |
let yellowView = UIView(frame: CGRect(x: 20, y: 20, width: 340, height: 100)) | |
yellowView.backgroundColor = .yellow | |
orangeView.addSubview(yellowView) | |
// Прямоугольник с координатами для конечного результата | |
var resultFrame = CGRect.zero | |
// Прямоугольник рандомный, с которым будем работать | |
let randomRect: CGRect = CGRect(x: 0, y: 0, width: 100, height: 50) | |
yellowView.frame | |
resultFrame = orangeView.convert(yellowView.bounds, from: yellowView) | |
let overlay = UIView(frame: resultFrame) | |
overlay.backgroundColor = UIColor(white: 1.0, alpha: 0.9) | |
overlay.layer.borderColor = UIColor.black.cgColor | |
overlay.layer.borderWidth = 1.0 | |
view.addSubview(overlay) | |
} | |
} | |
var coordinateSystem = CoordinateSystem() | |
PlaygroundPage.current.liveView = coordinateSystem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment