↓こちらのサイトを参考にして、画像の9スライスを試してみた。
self.frame.size = CGSize(width: 300, height: 50) let insets = UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50) let originalImage = UIImage(named: "btn_google_signin") let resizableImage = originalImage?.resizableImage(withCapInsets: insets, resizingMode: .tile) btnView.setBackgroundImage(resizableImage, for: .normal) btnView.imageView?.contentMode = .scaleToFill btnView.setTitle("Sign In with Google", for: .normal) btnView.titleLabel?.frame = CGRect(x: 50, y: 0, width: 300, height: 50) btnView.titleLabel?.font = UIFont.boldSystemFont(ofSize: 16) btnView.setTitleColor(UIColor(named: "btn_google_signin_text_color"), for: .normal) btnView.frame.size = CGSize(width: 300, height: 50) self.addSubview(btnView)