0

I want to make the screen like the following.

enter image description here

In source class, I write this code and push to side menu controller.

let vc = self.storyboard?.instantiateViewController(withIdentifier: "SidemenuController")as! SidemenuController

self.navigationController?.pushViewController(vc, animated: false)

I write the following code in destination controller view did load method but just color opacity is decreased data is not visible.

override func viewDidLoad() {
    self.view.backgroundColor = self.hexStringToUIColor(hex: "BE8790").withAlphaComponent(0.4)
}
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
ghrix ghrix
  • 29
  • 3
  • 7
  • I don't think you can achieve that using `push`, you need to present modally instead. See [Transparent background for modally presented viewcontroller](https://stackoverflow.com/questions/27669699/transparent-background-for-modally-presented-viewcontroller) – Dávid Pásztor May 28 '20 at 13:30

2 Answers2

0

Instead of using .withAlphaComponent(0.4)

Try this Adjust the number as needed

self.view.alpha = 0.5
Julian Silvestri
  • 1,970
  • 1
  • 15
  • 33
  • Value of type 'SidemenuController' has no member 'backgroundView' – ghrix ghrix May 28 '20 at 14:06
  • @ghrixghrix Please read my answer, I said use self.backgroundview is whatever view you are using as teh background. If it is the main view use the main view -> self.view.alpha = 0.5 – Julian Silvestri May 28 '20 at 14:17
0

You show present your SideViewController. Maybe custom how it shows

 let sideVC = // Your init
 sideVC.modalPresentationStyle = .fullScreen
 present(sideVC, animated: true, completion: nil)

In your SideViewController,

override func viewDidLoad() {
        super.viewDidLoad()
        view.alpha = 0.5
        view.backgroundColor = // Your color
        tableView.backgroundColor = .clear
}
King.lbt
  • 843
  • 5
  • 15