Let's say I have one or more 100*50 rectangular buttons on my ViewController.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func myButton(sender: UIButton) {
}
}
usually I put my graphic images as their image. then I apply auto layout.
BUT! I need them to be oblique not horizontal, I.E. if you have a square, I need to rotate it to be a diamond (45°), it's the same. I know it's not possible via interface builder. how to make it by code?
maybe I should use CGAffineTransformRotate or RotateTranform but I really don't know how to start
The best way to is rotate the views layer, CGAffineTransformMakeTranslation indicates the point in the layer where the layer will rotate around, remember layers go from (0,0) to (1.1) so the middle is (0.5, 0.5):