Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for z-index / transparent background / stacking of UIViews issue #98

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/node_modules/
/TODO
/NO_GIT/
/lib/libWebRTC-LATEST-Universal-Release.a
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why libWebRTC-LATEST-Universal-Release.a is removed from the repository.

/lib/.DS_Store
.DS_Store

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these lines from the .gitignore. OS's specific files can be globally ignored by creating your own HOME/.gitignore_global file.

8 changes: 8 additions & 0 deletions extra/hooks/iosrtc-swift-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module.exports = function (context) {
xcconfigPath = path.join(projectRoot, '/platforms/ios/cordova/build.xcconfig'),
xcodeProjectName = projectName + '.xcodeproj',
xcodeProjectPath = path.join(projectRoot, 'platforms', 'ios', xcodeProjectName, 'project.pbxproj'),
MainViewControllerPath = path.join(projectRoot, 'platforms', 'ios', projectName, 'Classes', 'MainViewController.m'),
swiftBridgingHead = projectName + BRIDGING_HEADER_END,
swiftBridgingHeadXcode = '"' + swiftBridgingHead + '"',
swiftOptions = [''], // <-- begin to file appending AFTER initial newline
Expand Down Expand Up @@ -99,6 +100,13 @@ module.exports = function (context) {
fs.appendFileSync(xcconfigPath, swiftOptions.join('\n'));
debug('file correctly fixed: ' + xcconfigPath);

var result = fs.readFileSync(MainViewControllerPath, 'utf8')
var rep ='theWebView.backgroundColor = [UIColor blackColor];';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that unused var rep for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That line should be stripped out, sorry about that.

result = result.replace('theWebView.backgroundColor = [UIColor blackColor];', 'theWebView.opaque = NO;');
fs.writeFileSync(MainViewControllerPath, result, 'utf8');
debug('MainViewController.m correctly fixed: ' + xcconfigPath);


// "project.pbxproj"
// Parsing it
xcodeProject.parse(function (error) {
Expand Down
21 changes: 16 additions & 5 deletions src/PluginMediaStreamRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ class PluginMediaStreamRenderer : NSObject, RTCEAGLVideoViewDelegate {

// The browser HTML view.
self.webView = webView
self.webView.opaque = false
self.webView.backgroundColor = UIColor.clearColor()
self.eventListener = eventListener
// The video element view.
self.elementView = UIView()
// The effective video view in which the the video stream is shown.
// It's placed over the elementView.
self.videoView = RTCEAGLVideoView()

self.webView.addSubview(self.elementView)
self.webView.bringSubviewToFront(self.elementView)

self.elementView.userInteractionEnabled = false
self.elementView.hidden = true
self.elementView.backgroundColor = UIColor.blackColor()
self.elementView.backgroundColor = UIColor.clearColor()
self.elementView.addSubview(self.videoView)
self.elementView.layer.masksToBounds = true

Expand Down Expand Up @@ -178,7 +177,19 @@ class PluginMediaStreamRenderer : NSObject, RTCEAGLVideoViewDelegate {
}

self.elementView.alpha = CGFloat(opacity)
self.elementView.layer.zPosition = CGFloat(zIndex)
self.elementView.tag = Int(zIndex)

var prevSiblingView: UIView?
for childView in (self.webView.superview?.subviews)!{
if(childView.tag > Int(zIndex)) {
prevSiblingView = childView;
break;
}
}

if let view = prevSiblingView {
self.webView.superview?.insertSubview(self.elementView, belowSubview: view)
}

if !mirrored {
self.elementView.transform = CGAffineTransformIdentity
Expand Down