Subview cannot be displayed in the camera preview in IOS with swift -
i use avfoundation
framework capture , display camera video preview , works. now, want add own uiimageview
on top of camera preview, here fragments of code.
previewlayer = avcapturevideopreviewlayer(session: capturesession) previewlayer!.videogravity = avlayervideogravityresizeaspect previewlayer!.connection?.videoorientation = avcapturevideoorientation.portrait previewlayer!.frame = previewview.bounds previewview.layer.addsublayer(previewlayer!) var imageview : uiimageview imageview = uiimageview(frame: cgrect(x: 130,y: 320,width: 60,height: 30)) imageview.image = uiimage(named:"scanbutton.png") previewview.addsubview(imageview) self.capturesession!.startrunning()
the "scanbutton.png" image file in project folder.
the uiimageview
cannot displayed. can tell what's wrong, thanks.
Comments
Post a Comment