0

I'm building a simple View with SideMenu. So if I try to click on it, I can see the option but the side menu is Under all items and not Over all items.

This is the code of ViewController:

[code] // // ViewController.swift // ArduinoHomeKit_bis // // Created by Michele Castriotta on 20/04/17. // Copyright © 2017 Michele Castriotta. All rights reserved. //

import UIKit import MessageUI

class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {

@IBOutlet weak var leadingConstraint: NSLayoutConstraint!
var menuShowing = false

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib
    view.layer.shadowOpacity = 1
    view.layer.shadowRadius = 6
   // sendText()


    self.navigationController?.navigationBar.barStyle = UIBarStyle.blackTranslucent

    self.navigationController?.navigationBar.barTintColor =
        getUIColorFromRGBThreeIntegers(red: 41,green: 151,blue: 214);
    self.view.backgroundColor =  getUIColorFromRGBThreeIntegers(red: 41,green: 151,blue: 255);

    //self.view.backgroundColor = ColorLiteral
}

func getUIColorFromRGBThreeIntegers(red: Int, green: Int, blue: Int) -> UIColor {
    return UIColor(red: CGFloat(Float(red) / 255.0),
                   green: CGFloat(Float(green) / 255.0),
                   blue: CGFloat(Float(blue) / 255.0),
                   alpha: CGFloat(1.0))
}

func sendText() {
    if (MFMessageComposeViewController.canSendText()) {
        let controller = MFMessageComposeViewController()
        controller.body = ""
        controller.recipients = ["3400963483"]
        controller.messageComposeDelegate = self
        self.present(controller, animated: true, completion: nil)
    }
}

func messageComposeViewController(_ controller: MFMessageComposeViewController!, didFinishWith result: MessageComposeResult) {
    //... handle sms screen actions
    self.dismiss(animated: false, completion: nil)
}

override func viewWillDisappear(_ animated: Bool) {
    self.navigationController?.isNavigationBarHidden = false
}


@IBAction func openMenu(_ sender: Any) {
    if(menuShowing){
        leadingConstraint.constant = -150;
    }else{
        leadingConstraint.constant = 0;
        UIView.animate(withDuration: 0.3, animations: {
            self.view.layoutIfNeeded()
        })

    }
    menuShowing = !menuShowing
}

} [/code]

And this is the output view:

enter image description here

bircastri
  • 2,169
  • 13
  • 50
  • 119

1 Answers1

0

I think the problem maybe cause by you add the left menu first, then you add some views. You can add the menuView in the last or can try bring menuView to front. Get your menu to IBOutlet and try this code:

[self.view bringSubviewToFront:menuView];
Quoc Le
  • 416
  • 3
  • 9