open func point(inside point: CGPoint, with event: UIEvent?) -> Bool open func convert(_ point: CGPoint, to view: UIView?) -> CGPoint open func convert(_ point: CGPoint, from view: UIView?) -> CGPoint open func convert(_ rect: CGRect, to view: UIView?) -> CGRect open func convert(_ rect: CGRect, from view: UIView?) -> CGRect
override func viewDidLoad() { super.viewDidLoad() view.addSubview(myButton) let center2 = view.convert(myButton.center, to: UIApplication.shared.keyWindow) }
view.convert(myButton.center, to: UIApplication.shared.keyWindow)
btn.contentEdgeInsets = .zero btn.imageEdgeInsets = UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 25) btn.titleEdgeInsets = UIEdgeInsets(top: 2, left: 12, bottom: 2, right: 2)
let btn = UIButton(type: .custom) btn.frame = CGRect(x: 100, y: 80, width: 40, height: 20) btn.setTitleColor(.white, for: .normal) btn.setTitle("jack", for: .normal) btn.titleLabel?.font = UIFont.systemFont(ofSize: 10) btn.setImage(UIImage.init(named: "loveHeat"), for: .normal) btn.backgroundColor = UIColor.black.withAlphaComponent(0.6) btn.layer.cornerRadius = 4; btn.layer.masksToBounds = true; btn.imageEdgeInsets = UIEdgeInsets(top: 3, left: 2, bottom: 1, right: 25) btn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 1, bottom: 0, right: 0) btn.isUserInteractionEnabled = false