I want to rotate a image in this code would be pic1. I placed a image below of what I am exactly looking for. I don't want to rotate the entire image I want to rotate from the bottom left corner of the rectangle 90 degrees. You can see specifically what I am talking about in the green circle. The rotation should take place in the button function.
import UIKit
class ViewController: UIViewController {
var pic1 = UIImageView()
var rot = UIButton()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
pic1.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(pic1)
rot.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(rot)
rot.backgroundColor = .blue
pic1.image = UIImage(named: "badMan.png")
NSLayoutConstraint.activate(
[
pic1.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.50),
pic1.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 1),
pic1.topAnchor.constraint(equalTo: view.topAnchor),
pic1.leadingAnchor.constraint(equalTo: view.leadingAnchor),
rot.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.50),
rot.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 1),
rot.topAnchor.constraint(equalTo: pic1.bottomAnchor),
rot.leadingAnchor.constraint(equalTo: view.leadingAnchor),
])
self.view.addSubview(pic2)
rot.addTarget(self, action: #selector(roate), for: .touchDown)
}
@objc func roate(){
}
}