Show an alert that looks like SKStoreReviewController

336 Views Asked by At

How can I show an alert thats similar to SKStoreReviewController?

I like how it looks and I want to use a similar UI on my app.

1

There are 1 best solutions below

3
On

Make a new view controller

let vc = UIViewController()
vc.preferredContentSize = CGSize(width: 250,height: 300)

Create everything you want on your view, for example a picker view

let pickerView = UIPickerView(frame: CGRect(x: 0, y: 0, width: 250, height: 300))
pickerView.delegate = self
pickerView.dataSource = self

Then add it to the view controller

vc.view.addSubview(pickerView)

With that you can create an alert view and set the view controller for the key contentViewController

let customAlert = UIAlertController(title: "Title", message: "", preferredStyle: UIAlertControllerStyle.alert)
customAlert.setValue(vc, forKey: "contentViewController")

let okAction = UIAlertAction(title: "OK", style: .default) {
    UIAlertAction in

        // what should happen when you click ok

    }


customAlert.addAction(okAction)
customAlert.addAction(UIAlertAction(title: "Abort", style: .cancel, handler: nil))
self.present(customAlert, animated: true)

Instead of adding a picker to the vc, you can also build the stuff you need for the review (Images, Labels, Slider, etc.)

Hope this helps.