我是iOS新手,请考虑..以下是我设计的屏幕

ios - 如何使用Swift在IOS中的另一个ImageVIew上显示一个Imageview-LMLPHP

AttendanceViewController

class AttendanceViewController: UIViewController,UIApplicationDelegate,
    UICollectionViewDelegateFlowLayout,UINavigationControllerDelegate,
    CLLocationManagerDelegate,UIImagePickerControllerDelegate {

    @IBOutlet weak var loginstatus: UILabel!
    @IBOutlet weak var displayloginimg: UIImageView!

    override func viewWillAppear(_ animated: Bool) {

        loginstatus.layer.zPosition = 1

    }

   // start give attendance
    @IBAction func giveLoginbtn(_ sender: Any) {

    }

}



  注意:当我在
  displayloginimg:UIImageView!我将此行添加为loginstatus.layer.zPosition = 1,因此显示为Login Label,但未显示“相机按钮”。

最佳答案

尝试使用bringSubviewtoFront方法将层次结构中的视图移动到另一个(而不是layer.zPosition)顶部的前面。

self.view.bringSubview(toFront: yourView)


码:

override func viewWillAppear(_ animated: Bool) {

    self.view.bringSubviewToFront(loginstatus)

}

// start give attendance
@IBAction func giveLoginbtn(_ sender: Any) {

    let camButton = sender as! UIButton
    self.view.bringSubviewToFront(camButton)
}

关于ios - 如何使用Swift在IOS中的另一个ImageVIew上显示一个Imageview,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53517499/

10-14 16:59
查看更多