gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 10:59:44 28 4
gpt4 key购买 nike

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

enter image description here

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) {

}

}

Note: Camera Button is not showing when I load image in the displayloginimg: UIImageView! I add this line loginstatus.layer.zPosition = 1 so Login Label is showing,But Camera Button is not showing..

最佳答案

尝试使用 bringSubviewtoFront 方法将层次结构中的 View 移动到另一个 View 的前面,而不是 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com